I think I messed up trying to save a Pandas Series that contained a bunch of Pandas Dataframes. Turns out that the DataFrames were each saved as if I called df.to_string()
on them.
From my observations so far, my strings have extra spacing in some places, as well as extra \
when the DataFrame has too many columns to be displayed on the same row.
Here is a "more appropriate DataFrame:
df = pd.DataFrame(columns=["really long name that goes on for a while", "another really long string", "c"]*6,
data=[["some really long data",2,3]*6,[4,5,6]*6,[7,8,9]*6])
The strings that I have and wish to turn into a DataFrame look like this:
# str(df)
' really long name that goes on for a while another really long string c \\\n0 some really long data 2 3 \n1 4 5 6 \n2 7 8 9 \n\n really long name that goes on for a while another really long string c \\\n0 some really long data 2 3 \n1 4 5 6 \n2 7 8 9 \n\n really long name that goes on for a while another really long string c \\\n0 some really long data 2 3 \n1 4 5 6 \n2 7 8 9 \n\n really long name that goes on for a while another really long string c \\\n0 some really long data 2 3 \n1 4 5 6 \n2 7 8 9 \n\n really long name that goes on for a while another really long string c \\\n0 some really long data 2 3 \n1 4 5 6 \n2 7 8 9 \n\n really long name that goes on for a while another really long string c \n0 some really long data 2 3 \n1 4 5 6 \n2 7 8 9 '
How would I revert a string like this back to a DataFrame?
Thanks