let say I have ID parameter
ID=[20020,54125,45698,54220]
I want to filter only numbers that have "20" in ID.
20020
54220
whats the best way to do that? `
ID=[20020,54125,45698,54220]
df = pd.DataFrame(ID)
Use Series.str.contains
:
In [656]: df[df[0].astype(str).str.contains('20')]
Out[656]:
0
0 20020
3 54220
Note: As per @Jonas' comment, Here 0
is the name of column.