Selecting Pandas Columns by dtype

后端 未结 9 2056
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 01:22

I was wondering if there is an elegant and shorthand way in Pandas DataFrames to select columns by data type (dtype). i.e. Select only int64 columns from a DataFrame.

<
9条回答
  •  悲&欢浪女
    2020-11-29 01:54

    You can use :

    for i in x.columns[x.dtypes == 'object']:   print(i)
    

    incase you just want to display only the column names of a particular dataframe rather than a sliced dataframe. Don't know if any function as such exits for python.

    PS : replace object with the datatype you want.

提交回复
热议问题