回答編集履歴

1

追記

2020/01/18 16:54

投稿

can110
can110

スコア38266

test CHANGED
@@ -1,3 +1,35 @@
1
+ 単純に`@`が含まれているかだけで判断してよければ[pandas.Series.str.contains](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.contains.html)が使えます。
2
+
3
+ ```Python
4
+
5
+ import pandas as pd
6
+
7
+
8
+
9
+ df = pd.DataFrame({'msg':['ab','@cd','@ef@']})
10
+
11
+ df['ret'] = df['msg'].str.contains('@') * 1
12
+
13
+ print(df)
14
+
15
+ """
16
+
17
+ msg ret
18
+
19
+ 0 ab 0
20
+
21
+ 1 @cd 1
22
+
23
+ 2 @ef@ 1
24
+
25
+ """
26
+
27
+ ```
28
+
29
+
30
+
31
+ #### 以下、問題を勘違いしていたようなので取り消し
32
+
1
33
  [pandas.Series.str.count](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.count.html)で個数を得ることができます。
2
34
 
3
35
  ```Python