I have a csv file that its rows look like this
q4_1,"blabla,bla",new_label q4_2,alb,new_label2
and I would like to read it in a pandas
data.frame
that will look like this
import pandas as pd
pd.DataFrame({'col1' : ['q4_1','q4_2'],
'col2' : ['blabla,bla','alb'],
'col3' : ['new_label','new_label2']})
Which parameter in the pd.read_csv
function should I use for that ? I couldn't figure it out from the documentation
With python 3.7 and pandas 0.23.4 , worked this:
import pandas as pd
df0 = pd.read_csv('data.csv', names=["col1", "col2", "col3"], squeeze=True)
the result is a DataFrame with the structure described in the question:
col1 col2 col3
0 q4_1 blabla,bla new_label
1 q4_2 alb new_label2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.