How to convert a string to a dataframe in Python

How to convert a string to a dataframe in Python

It seems you can use:

from pandas.compat import StringIO
df = pd.read_csv(StringIO(response))

But maybe also works:

df = read_csv(URL)

use read_fwf and to_csv() then read_csv()

import io 
import pandas as pd

df = pd.read_fwf(io.StringIO(response))

df.to_csv(data.csv)

result_df = pd.read_csv(data.csv,)

How to convert a string to a dataframe in Python

Leave a Reply

Your email address will not be published. Required fields are marked *