0
我有一個數據幀df,列作爲column1 通過使用str.match我如何檢查列值是否在任何一個值('Value1','值2' )str.match()Python匹配任何一個值
這是可以做到這樣
(df['column1'].str.lower().str.match(Value1')) | (df['column1'].str.lower().str.match('Value2'))
或像這樣通過使用lambda表達式:
df[column1].apply(lambda x : True if x in ['Value1','Value2'] else False)
尋找類似的東西
(df['column1'].str.lower().str.match('Value1' | 'Value1'))
是的,這是我想要的。 –