python - Is it possible to modify a df from pandas function read_html before pasting into a csv file? -
i able pull df reading html function in pandas reason not able modify columns if select table want since pulling tables reference 1 want.but when comes changing name of columns or specific piece of data printing column, can't figure out. out there know's how deal this. here example:
import pandas pd url= 'http://www.espnfc.com/barclays-premier-league/23/table' df = pd.read_html(url) print(df) print(df[0].home) '✔ works print(df[0][unnamed: 17]) 'throw's me error df.rename(columns = {'away':'awayy2'}, inplace = true) 'throw's me error
df[0]['unnamed: 17'] df[0].rename(columns = {'away':'awayy2'}, inplace = true)
above works me. (apostrophe & [0] missed)
Comments
Post a Comment