简体   繁体   中英

Group columns in dataframe, Multiindex pandas

I am calculating some correlations for a set of measures. 数据框

For each measure, I have a data frame of the look attached, which I will join in one data frame.

I want to add multilevel indexing, with the name of the measure, above the columns I have. What is the best way of doing so?

You can use corr to find the correlations within your columns

df.corr()

Use this to split CI95% column into two columns

df[['CI95%_1','CI95%_2']] = pd.DataFrame(df['CI95%'].tolist(), index= df.index)

Then use corr()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM