我想删除任何行中没有内容的列,并删除以相同名称开头的其他列。
在此示例中,应删除Line of Business > Organization,因为所有行中只有空白。由于此列已删除,所有其他以“业务线 >”开头的列也应从 pandas 数据框中删除。完整的数据框遵循[some text] > [Organization/Department/Employees]相同的结构。
data = pd.DataFrame({'Process name': {0: 'Ad campaign', 1: 'Payroll', 2: ''},
'Line of business > Organization': {0: "", 1: "", 2:''},
'Line of business > Department': {0: "Social media", 1: "People", 2:''},
'Line of business > Employees': {0: "Linda, Tom", 1: "Manuel, Olaf", 2:''}})
结果:
output = pd.DataFrame({'Process name': {0: 'Ad campaign', 1: 'Payroll', 2: ''}})
MMTTMM
相关分类