简体   繁体   中英

My code is throwing an error on a groupby function I used

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()

the error code:

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

I am trying to group by {raw_material} Lot

As Klaus D. mentioned in comment:

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

is a nested list instead of dataframe.

thats why you are getting error on:

ccmb1_qc_endo_df.groupby(f"{raw_material} Lot").mean().reset_index()

<class 'AttributeError'>: 'list' object has no attribute 'groupby'

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