如果column1的用户名== column2,则在column2中打印区域 要求的输出量应为
QName Region Username
ModemSW_Rf india karthik
Qipl_IOT India Raj
Qipl_IOT India Ram
Qipl_IOT china xin
Qipl_IMS India Rahul
Qipl_IMS India sriram
答案 0 :(得分:1)
我认为您需要替换Region
列中的缺失值,然后使用boolean indexing
和duplicated
每2列获取所有重复项:
df['Region'] = df['Region'].ffill()
df[df.duplicated(subset=['Region','Username'], keep='last')]
或者可能需要notna
来过滤没有缺失值的行:
df['Region'] = df['Region'].ffill()
df[df['Q Name'].notna()]
另一种解决方案:
df = df.dropna(subset=['Q Name'])