1

I am training a CNN, an excel has many classes to train and I just want to work with only 3.

What happens is that when I'm filtering it, in the header it comes out ", img_name, name" that comma at the beginning I don't know where it comes from, nor how it was done.

Attached code

# This might takes a while to search all these urls
subperson_img_url = [images_boxable[images_boxable['image_name']==name+'.jpg'] for name in subperson_img_id]
subphone_img_url = [images_boxable[images_boxable['image_name']==name+'.jpg'] for name in subphone_img_id]
subcar_img_url = [images_boxable[images_boxable['image_name']==name+'.jpg'] for name in subcar_img_id]


    subperson_pd = pd.DataFrame()
    subphone_pd = pd.DataFrame()
    subcar_pd = pd.DataFrame()
    for i in range(len(subperson_img_url)):
        subperson_pd = subperson_pd.append(subperson_img_url[i], ignore_index = True)
        subphone_pd = subphone_pd.append(subphone_img_url[i], ignore_index = True)
        subcar_pd = subcar_pd.append(subcar_img_url[i], ignore_index = True)
    subperson_pd.to_csv('/content/drive/My Drive/AI/Dataset/Open Images Dataset v4 (Bounding Boxes)/subperson_img_url.csv')
    subphone_pd.to_csv('/content/drive/My Drive/AI/Dataset/Open Images Dataset v4 (Bounding Boxes)/subphone_img_url.csv')
    subcar_pd.to_csv('/content/drive/My Drive/AI/Dataset/Open Images Dataset v4 (Bounding Boxes)/subcar_img_url.csv')

So, when it saved in that location, when I open it, it appears like the image below:

enter image description here

Does anyone know what I am wrong about? any help is fine, thanks!

3
  • Can you provide a sample of what is there in subperson_img_url? Commented Dec 4, 2019 at 5:31
  • Edited question Commented Dec 4, 2019 at 6:22
  • What happens if you don't use the ignore_index=True in the append() function? Commented Dec 4, 2019 at 8:35

1 Answer 1

1

If you save the file using .to_csv the default behavior is to save the index as well, but you have not defined the index name, therefore you have the empty string and a comma.

To solve this you can either omit the index:

subcar_pd.to_csv(filename, index=False)

or name it:

subcar_pd.to_csv(filename, index=True, index_label='index')
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.