我有这个https://pastebin.com/BYUdR7PW sample.xlsx,我想过滤YES和NO并将它们保存在一个文件中,其中包含一个包含yes的文件和另一个没有相应列的文件值(标题和带有是/否的列) 我是熊猫新手,我正在使用的代码是
labels = 'sample.xlsx'
df = pd.read_excel(labels)
df = pd.read_excel(labels)
# df2 = df2.set_index('Notes_PRODUCER NAME:').to_dict()
# df =df2.T
df.columns = df.columns.str.replace('\s+', '_') # in case there are multiple white spaces
df = df.set_index('Notes_PRODUCER_NAME:')
df = df.where(df.isin(['yes','no'])).stack().reset_index(name='val')
# #get for each User unique columns names
df = df.groupby('Notes_PRODUCER_NAME:')['level_1'].unique().reset_index(name='un_val')
df
我怎么能这样做,因为我的代码不能正常工作
结果我想要像这个
Notes_PRODUCER NAME: | FV 5.2 Sanitary Facilities_Compliance
Swahn |
| yes
| yes
yes
Swahn | Notes_DOES THE PRODUCER MAKE USE OF A CONSULTANT?
NO
|
|
Sarah | Notes_IS THE PRODUCER REGISTERED FOR PARALLEL PRODUCTION?
NO