Search code examples
pythonpandasdataframecsvtolist

Format problem: pandas df.values.tolist() is converting rows into lists but lists each have just one item


Table with 4 Columns and 10 Rows. Reading in as dataframe(df).

Then from there using lists = df.values.tolist() produces print(lists)

Outcome:

[['30;30;30;0'], ['30;30;30;0'], ['30;30;30;0'], ['30;30;30;0'], ['30;30;30;0'], ['30;30;30;0'], ['30;30;30;0'], ['30;30;30;0'], ['30;30;30;0'], ['30;30;30;0']]

Problem: Why are the values separated by semicolon instead of a comma. Each list has then just one value. :/ I followed exactly the documentation.


Solution

  • I changed first my european standard delimiter, that was not helping even after making a new csv file and loading it up into python.

    It is much easier solvable by just: adding in the pandas read:

    data = read_csv(csv_path, **sep=';')**
    

    Thanks Joanis for the hint.

    here to find: How to read a file with a semi colon separator in pandas