I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
I’ve run into this issue before and I’m not 100% sure why this happens.
My best guess is that when Pandas reads in the data, it guesses which type the data is in each column. This means it can guess wrong and try to coerce data into a type that it’s not going to work with.
my solution to this has been to create a dictionary with column names and the types I want them to be something that looks like this