こうかなー
python
1import pandas as pd
2
3df = pd.DataFrame({ '生年月日' : [
4 'lllllllll', # All Small L
5 '|||||||||', # All vertical bar
6 '111111111', # All Number
7 '1111|llll'
8 ]})
9
10
11a = df['生年月日'].str.find('|') !=-1
12
13print(type(a))
14"""
15<class 'pandas.core.series.Series'>
16"""
17
18print(a)
19"""
200 False
211 True
222 False
233 True
24"""
25
26print(a.sum())
27"""
282
29"""
30
31print(df[a])
32"""
33 生年月日
341 |||||||||
353 1111|llll
36"""
こちらTrueの数をカウントする方法はありますでしょうか???
pandas.Series.sumを使ってください。
df['生年月日'].str.find('|') !=-1の演算結果はpandas.Series型です。
sum関数はTrueを1、Falseを0として合計しますのでこれでTrueの数を数えられます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/12/03 00:15