I'm learning python and currently trying to pull rows by specific keywords found in a column and save to a new csv file. Also, I'm trying to find a best way to get any possible hits for my keyword (ex: inc, Inc, INC, InC etc.):
My input.csv
id name
1 ACME
2 Micro inc
3 Barber GmBH
4 Pizza Place
Desired output:
id name 2 Micro inc 3 Barber GmBH
My code so far:
import pandas as pd
df = pd.read_csv('/path/to/mynewtestfile.csv')
df[df['name'].str.contains("ball", "inc", "gmbh")]
df.to_csv('path/to/my/output.csv', index=False)
However, I received this error:
TypeError: unsupported operand type(s) for &: 'str' and 'int'
Could someone help me with this? thanks in advance!