23
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pandas(DataFrame,Series)のbool値をint型(0,1)に一瞬で変換する方法

Posted at

1をかけるだけでOKです

sample.py
import pandas as pd
#DataFrame
df = pd.DataFrame({'A': (True, False, True),})
df * 1

#Series
sr = pd.Series([True, False, True],index=[0,1,2])
sr * 1

20181228-121452.jpg

23
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?