I want to save pandas table in a file, so I can read it from that file later. My requirements:
the file format should be decently portable (good library support on Windows/Linux in major languages)
the DataFrame I read should be absolutely identical to the one I saved
According to this post, read_csv
and to_csv
may work if I provide index_col=0
argument, but the datatypes are lost (and of course, automatic type inference doesn't guarantee to give me the same types even for simple types, not to mention if I use python objects like list
s which are never inferred).
Is there some simple solution that just works for sure, without having to worry about many edge cases?
The only solution I can think of, is using to_csv
/ read_csv
, but save type information somewhere else. Still, I'm afraid there might more hidden problems (like duplicate column names, etc.).