AttributeError: 'list' object has no attribute 'loc'怎么解决
%matplotlib inline
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings('ignore')
plt.rc("font",family="SimHei",size="15") #解决中文乱码问题
excelFile=r'E:\计算机大作业\nmicrobiology图表复现\COPD_multiomics-main\COPD_multiomics-main\6-Figure scripts\Fig E2 Source Data.xlsx'
df=pd.DataFrame(pd.read_excel(excelFile,sheet_name='Bacterial load'))
df1=[['Group_Site','log10cpn']]
df2=df1.loc[df1['Group_Site']=='Guangzhou_C']
print(df2)
报错:AttributeError Traceback (most recent call last)
Cell In[12], line 12
10 df=pd.DataFrame(pd.read_excel(excelFile,sheet_name='Bacterial load'))
11 df1=[['Group_Site','log10cpn']]
-> 12 df2=df1.loc[df1['Group_Site']=='Guangzhou_C']
13 print(df2)
AttributeError: 'list' object has no attribute 'loc'