pythonpandasdataframecsvutf-8

Trouble reading CSV file using pandas


I'm working on a data analysis project & I wanted to read data from CSV files using pandas. I read the first CSV file and It was fine but the second one gave me a UTF 8 encoding error. I exported the file to csv and encoded it to UTF-8 in the numbers spreadsheet app. However, the data frame is not in the expected format. Any idea why? code in Jupyter notebook

the original CSV file in numbers the original CSV file in numbers


Solution

  • it looks like your file is semicolon separated not comma separated. To fix this you need to add the sep=';' parameter to pd.read_csv function.

    pd.read_csv("mitb.csv", sep=';')