I know that DataFrame can be be converted to string using to_string function:
import pandas as pd
df = pd.DataFrame({'A' : ['one', 'one', 'two', 'three'] * 3,
'B' : ['Aa', 'Bb', 'Cc'] * 4})
dfstr = df.to_string()
print(dfstr)
Output:
A B
0 one Aa
1 one Bb
2 two Cc
3 three Aa
4 one Bb
5 one Cc
6 two Aa
7 three Bb
8 one Cc
9 one Aa
10 two Bb
11 three Cc
How can I convert this dfstr
back to a DataFrame object?
Edit:
I am asking specifically how the string created by df.to_string()
function can be converted back to a dataframe object, not about general ways of converting text data (string) to dataframes as discussed on How to create a Pandas DataFrame from a string .