我正试图反复浏览一系列股票名称和价格“AAPL_high”是有效的,因为没有其他股票具有相同的名称
但是,在“F_high”上,下面的代码查找“F_high”,并列出包含字符串的其他股票,例如“CF_high”和“COF_high”。我只需要'F_high',没有其他包含额外字符的字符串
stocks_of_interest = ['AAPL_high', 'F_high']
df = pd.read_csv('test.csv')
for i in stocks_of_interest:
print(i)
indiv = df[df['level_0'].str.contains(i)]
print(indiv)
我应该向str.contains()传递另一个参数以进一步细化它,还是使用不同的筛选方法?先谢谢你
以匹配dataframe中的字符串。你能行
相关问题 更多 >
编程相关推荐