我在pandas创建了一个数据透视图数据框,它的列分为两个级别 如何删除第一级?
+---+
|ids|
+---+
| 1|
| 2|
| 3|
| 5|
| 6|
| 7|
| 8|
| 9|
| 10|
+---+
+---+
|ids|
+---+
| 6|
| 7|
| 7|
| 9|
| 10|
+---+
+---+
|ids|
+---+
| 1|
| 3|
| 7|
| 8|
| 9|
+---+
结果
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
% matplotlib inline
df=pd.read_csv('file01.csv')
grouped_df=df.groupby(['neighborhood','bedrooms'],as_index= False).mean().round()
pivot_df=grouped_df.pivot(index='bedrooms',columns='neighborhood')
pivot_df.columns
我想删除['price'],因为当我要过滤picot_dataframe时会显示此错误
MultiIndex(levels=[['price'], ['ANDON', 'ANTIBES', 'ASCROS', 'ASPREMONT', 'AURIBEAU-SUR-SIAGNE']])
错误
pivot_df['ANDON','ANTIBES']