0nir
0nir

Reputation: 1355

"Like" condition instead of an "isin" in pandas

I have a parameter dictionary as below -

paramDict = {
    "DataFilter": {
        "tableField": [{
            "table":"GL_LEDGERS",
            "field":"NAME"
        }],
        "value" : ["ABC."]
    }
} 

Now I want to use a "like" instead of the "isin" condition so that the data gets filtered for "ABC" as well as "ABC." -

DataFilter = df['NAME'].isin(
    pd.Series(paramDict['DataFilter']['value']))
df = df[DataFilter]

Can you please help me with the same. I am using python 2.7. Thanks.

Upvotes: 0

Views: 2711

Answers (1)

kennes
kennes

Reputation: 2145

I assume your Series is a string type.

If so, you can use .contains:

DataFilter = df['NAME'].str.contains('ABC')

Upvotes: 3

Related Questions