Issue
I am facing a problem opening a csv file with pandas. Here is what I get.
I thought to transform row data into a string and then split them at ;
. Unfortunately,
dataset.iloc[0]
outputs
age;"job";"marital";"education";"default";"balance";"housing";"loan";"contact";"day";"month";"duration";"campaign";"pdays";"previous";"poutcome";"y" 30;"unemployed";"married";"primary";"no";1787;...
Name: 0, dtype: object
and dataset.iloc[5]
outputs
age;"job";"marital";"education";"default";"balance";"housing";"loan";"contact";"day";"month";"duration";"campaign";"pdays";"previous";"poutcome";"y" 35;"management";"single";"tertiary";"no";747;"...
Name: 5, dtype: object
Not all data are available in iloc
command.
However, when I Double-click on the file to open it, I can see that it is well formatted.
Could anyone help me with this? Thank you in advance.
Solution
Add sep=";"
to your read_csv
command:
pd.read_csv(dfile, header=0, sep=';')
Answered By - mozway
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.