对Pandas数据透视表功能不熟悉。 我遵循本指南[1]。 修改现有的excel文件并尝试创建表输出。
im试图像这样索引数据透视表;
def generate_invoice_summary_info():
file_path = 'output.xlsx'
df = pd.read_excel(file_path, sheet_name='Invoice Details', usecols="E:G,I,L:N")
df["Invoice Cost Centre"] = df["Invoice Cost Centre"].astype("category")
df["Invoice Cost Centre"].cat.set_categories(["RIM", "R3TM", "D3TM", "R5M"], inplace=True)
df['Price'] = df['Price'].astype(str)
df['Period From'] = df['Period From'].astype(str)
pd.pivot_table(df, index=["Invoice Cost Centre", "Invoice Category"])
出现以下错误
pandas.core.base.DataError: No numeric types to aggregate
为什么会出现此错误? 我正在尝试根据“发票费用中心”,“发票类别”列汇总表格