我的代码在我使用的groupby函数上抛出错误


ccmb1_qc_endo_df = read_qc_endotoxin(ccmb1_qc_data_df)
raw_material = "CCMB1"
ccmb1_qc_endo_df[f"{raw_material} Lot"] = ccmb1_qc_endo_df[f"{raw_material} Lot"].astype(str)
ccmb1_qc_endo_df = [[f"{raw_material} Lot", "Avg Endotoxin (EU/kg)",
"AVG Osmo mOsm/kg", "AVG Bioburden CFU/mL"]]
ccmb1_qc_endo_df = ccmb1_qc_endo_df.groupby(f"{raw_material} Lot").mean().reset_index()

错误码:

Job failed: Error in Python process: At line 61: <class 'AttributeError'>: 'list' object has no attribute 'groupby'. Line 61 i the last line of code for the syntax above

我正在尝试按{raw_material}批次分组

正如Klaus D.在评论中提到的:

ccmb1_qc_endo_df = [[f"{raw_material} Lot", "Avg Endotoxin (EU/kg)",
"AVG Osmo mOsm/kg", "AVG Bioburden CFU/mL"]]

是一个嵌套列表,而不是dataframe。

这就是为什么你得到错误:

ccmb1_qc_endo_df.groupby(f"{raw_material} Lot").mean().reset_index()
<class 'AttributeError'>: 'list' object has no attribute 'groupby'

相关内容

  • 没有找到相关文章

最新更新