我想知道是否有办法使用Python搜索关键字列表。我可以使用PostgreSQL搜索我的数据。这是我的PostgreSQL代码
-- | Properties to check that the 'Applicative' @m@ satisfies the applicative
-- properties
applicative :: forall m a b c.
( Applicative m
, Arbitrary a, CoArbitrary a, Arbitrary b, Arbitrary (m a)
, Arbitrary (m (b -> c)), Show (m (b -> c))
, Arbitrary (m (a -> b)), Show (m (a -> b))
, Show a, Show (m a)
, EqProp (m a), EqProp (m b), EqProp (m c)
) =>
m (a,b,c) -> TestBatch
applicative = const ( "applicative"
, [ ("identity" , property identityP)
, ("composition" , property compositionP)
, ("homomorphism", property homomorphismP)
, ("interchange" , property interchangeP)
, ("functor" , property functorP)
]
)
where
identityP :: m a -> Property
compositionP :: m (b -> c) -> m (a -> b) -> m a -> Property
homomorphismP :: (a -> b) -> a -> Property
interchangeP :: m (a -> b) -> a -> Property
functorP :: (a -> b) -> m a -> Property
identityP v = (pure id <*> v) =-= v
compositionP u v w = (pure (.) <*> u <*> v <*> w) =-= (u <*> (v <*> w))
homomorphismP f x = (pure f <*> pure x) =-= (pure (f x) :: m b)
interchangeP u y = (u <*> pure y) =-= (pure ($ y) <*> u)
functorP f x = (fmap f x) =-= (pure f <*> x)
我不知道Python是否是最好的方法,但我复制的工作使用Python并且希望坚持使用Python。
我能够搜索一个关键字,但不知道如何做多个。
SELECT distinct ON (id) id, year, cost, description
FROM mydata
WHERE description similar to'%((hotel)||(travel)|(taxi)|(food))%';
我需要帮助
1)使用多个关键字进行搜索
2)将数据导出回csv
的方法答案 0 :(得分:0)
> import pandas as pd
使用contains
进行多个关键字搜索> df = pd.read_csv('mydata.csv')
> df[df.description.str.contains('hotel|travel|taxi|food')]
导出到csv
> df.to_csv('new.csv')