简体   繁体   中英

Remove Semicolons as Line Delimiters Reading csv-file Using pandas.read_csv

I'm working with a pandas dataframe that I want to plot. Instead of being float numbers, some values inside the dataframe are strings because they have a semicolon. This causes a ValueError when the dataframe is to be plotted. I have found out that the semicolons only occur at the end of each line.

Is there a keyword in the read_csv method to let pandas recognize the semicolons so they can be removed?

If the semicolon is being used to separate lines, you can use the lineterminator parameter to correctly parse the file:

pd.read_csv(..., lineterminator=";")

Pandas CSV documentation

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM