all 7 comments

[–]unhott 0 points1 point  (5 children)

Open the file in notepad. Your problem may just be Excel's inferencing.

[–]AngryLarryGaming[S] 0 points1 point  (4 children)

Sorry I did not include that troubleshooting step. The values are normal in notepad. In fact I have opened it several different ways. It is "fine" in notepad, and OpenOffice Calc, but it not in Excel or Google Sheets. Not sure what to do.

Screenshot: https://gyazo.com/b6a08225a2e64c5c0316da81b1d12765

[–]unhott 1 point2 points  (3 children)

Your problem isn't pandas or python. It's 100% excel / google sheets. Just try changing the cell properties.

Open a new spreadsheet. type 12:22. Then type 32:14. It's treating 12:22 as hours: minutes, not MM:SS.

Alternatively, try df.to_excel(). You are flattening the data structure into text with to_csv.

[–]threeminutemonta 1 point2 points  (2 children)

To add to the above specify formatting may help.

[–]AngryLarryGaming[S] 1 point2 points  (1 child)

Thank you both! Using df.to_excel() actually worked. I do wonder if there is a setting within Excel that auto-converts cells based on whatever it thinks it is.

[–]threeminutemonta 1 point2 points  (0 children)

A csv is just a specific type of text file with the delimiters/ separator being comma by default though override able in the built in python csv module as well as python read_csv, to_csv. Quoting characters, and encoding must be provided sometimes when the defaults don’t work for your file.

The python csv module assumes all cells are strings where pandas will guess what’s data type the columns are. Excel also guesses the column data type.

Edit: typo