LoginSignup
3

More than 5 years have passed since last update.

DataFrame の列から特定のタイプ(str, float etc)の列を探す方法

Posted at

DataFrame の列から特定のタイプ(str, float etc)の列を探す方法

Age City
0 21 Tokyo

というデータフレームがあった場合。

bool値で返す場合


df.dtypes == object

>>
Age False
City True
dtype: bool

列を返す場合


df.loc[:, df.dtypes == object]

>>
    Age    City
0   21    Tokyo

列の名前をリストに格納する場合


mylist = list(df.select_dtypes(include = ['object']).columns)

mylist 

>>
['City']


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
3