I have a df like this:
Allotment Year NDVI A_Annex Bachelor
A_Annex 1984 1.0 0.40 0.60
A_Annex 1984 1.5 0.56 0.89
A_Annex 1984 2.0 0.78 0.76
A_Annex 1985 3.4 0.89 0.54
A_Annex 1985 1.6 0.98 0.66
A_Annex 1986 2.5 1.10 0.44
A_Annex 1986 1.7 0.87 0.65
and I want to write each column to a new dataframe, and a subsequent csv based on the column name. So I want a new csv for the contents of each column.
so far I have done this:
outpath='C:\'
for column in df:
x=pd.DataFrame(df[column])
outpath=outpath + column + '.csv'
x.to_csv(outpath)
but column contains every single column name, when I only want to write to separate ones. My desired file names would be something like Allotment.csv, Year.csv, NDVI.csv, A_Annex.csv, Bachelor.csv
for column in df: df[column].to_csv( 'C:\' + column + '.csv')YearandA_Annextogether?