我有一个数据帧列表,我想在其中循环所有的数据帧,并通过附加列来创建数据帧。下面是代码
#df_ls contains list of dataframes
df_ls = [A, B, C, D]
for j in df_ls:
match_ls = ['card', 'brave', 'wellness']
for i in text:
if i in j.columns:
print(i)
df1 = j[i]
df2 = df1
df_full = df2.append(df1)
需要结果新的dataframe与单列包含所有匹配的字符串值
A
card banner
rex 23
fex 45
jex 66
B
brave laminate
max ste
vax pre
jox lex
expected output
rex
fex
jex
max
vax
jox
对按^{} 筛选列名称使用列表理解,最后使用^{} 连接在一起:
循环版本:
相关问题 更多 >
编程相关推荐