python - Converting rows in pandas dataframe to columns -
i want convert rows in foll. pandas dataframe column headers:
transition area 0 a_to_b -9.339710e+10 1 b_to_c 2.135599e+02
result:
a_to_b b_to_c 0 -9.339710e+10 2.135599e+02
i tried using pivot table, not seem give result want.
i think can first set_index
column transition
, transpose t
, remove columns name rename_axis
, last reset_index
:
print df.set_index('transition').t.rename_axis(none, axis=1).reset_index(drop=true) a_to_b b_to_c 0 -9.339710e+10 213.5599
Comments
Post a Comment