"\...">Geek Answers HandbookCheck for a character in the string list.Python indoes not work for whole columns:> dfTrain['name'][22] 'McGowan, Miss. Anna "Annie"' > "\"" in dfTrain['name'][22] True > "\"" in dfTrain['name'] False How to check if a character is in the string list?+4python pandasYari Apr 21 '16 at 16:54source share3 answersThere may be several ways:1) One of the things you can do is"\"" in dfTrain['name'].to_string() This returns Trueif any of the names in df contains ".2) Another way could be not dfTrain[dfTrain['name'].str.contains('"')].empty, , ". , ", , dataframe . dataframe (True), ", , "False" (, "" )+1CoderBC 22 . '16 14:49"\" " dfTrain ['name'] [22] - " , "Annie", "\"dfTrain ['name'] - , "\":>>> nested_list_example = ["abhishek","ralesh","wr'"] >>> "wr'" in nested_list_example True >>> "'" in nested_list_example False >>> "'" in nested_list_example[2] True +3abhinsit 21 . '16 16:58join() contains(), , ":In [11]: df Out[11]: name 0 [test1, test2] 1 [another test] 2 [yet, another test] 3 [McGowan, Miss. Anna "Annie", aaa, bbb] In [12]: df['name'].str.join('').str.contains('"') Out[12]: 0 False 1 False 2 False 3 True Name: name, dtype: bool 0MaxU 21 . '16 17:41More articles:How does the header file know where the function prototype is implemented? - cHTML submission request (login form) - javaSymfony 3.0.4 A circular link detected during serialization using FOSRestBundle - restDisable responses but save crash reports for Fabric - iosHighlight Focused Field Cordova - javascriptКакой доступный способ группировать элементы в радиогруппе? (HTML5/WAI-ARIA) - htmlПредотвращение множественных кликов по ссылке с помощью JS или jquery - javascriptGo concurrency with a loop and an anonymous function behaves unexpectedly - goCreate a visible element and hide it when clicked - javascriptCard with indifferent access to keys - elixirAll Articles
Python indoes not work for whole columns:
in
> dfTrain['name'][22] 'McGowan, Miss. Anna "Annie"' > "\"" in dfTrain['name'][22] True > "\"" in dfTrain['name'] False
How to check if a character is in the string list?
There may be several ways:
1) One of the things you can do is
"\"" in dfTrain['name'].to_string()
This returns Trueif any of the names in df contains ".
True
2) Another way could be not dfTrain[dfTrain['name'].str.contains('"')].empty
not dfTrain[dfTrain['name'].str.contains('"')].empty
, , ". , ", , dataframe . dataframe (True), ", , "False" (, "" )
"
"\" " dfTrain ['name'] [22] - " , "Annie", "\"
dfTrain ['name'] - , "\"
:
>>> nested_list_example = ["abhishek","ralesh","wr'"] >>> "wr'" in nested_list_example True >>> "'" in nested_list_example False >>> "'" in nested_list_example[2] True
join() contains(), , ":
join()
contains()
In [11]: df Out[11]: name 0 [test1, test2] 1 [another test] 2 [yet, another test] 3 [McGowan, Miss. Anna "Annie", aaa, bbb] In [12]: df['name'].str.join('').str.contains('"') Out[12]: 0 False 1 False 2 False 3 True Name: name, dtype: bool