Get data from a specific column in CSV

0

I have a question in an exercise. I have a table where I need to get results from only one column.

The data is as follows: ['2017-01-01 00:27:45', '2017-01-01 00:31:13', '208', 'Damen Ave & Chicago Ave ',' Damen Ave & Division St ',' Subscriber ',' Male ',' 1982.0 ']]

In case I need to obtain the gender (male and female of the first 20 samples) ... The way I'm doing I can not just get this column and I'm just pulling line 6 all over ....

Can you give me some help?

1

    
asked by anonymous 04.05.2018 / 20:45

1 answer

0

Juliana advised you to use the Pandas library to work with CSV.

In this case you could proceed as follows:

import pandas as pd

Once the library is imported, you must load the file. In the case below you did not enter the header, I left the HEADER flag as ' None '

df = pd.read_csv('CAMINHO DO SEU ARQUIVO', header= None)

After this the file has already been loaded, and you can use the command df.info() to see how it was.

In the example that you gave to get the data of the column that represents the genre just write the command:

print(df[6])

Follow the image with an example database that I put together.

ThePANDASlibraryisoftenusedtorecommendthis LINK as an introductory content

    
04.05.2018 / 21:18