get list of pandas dataframe columns based on data type

前端 未结 12 1374
后悔当初
后悔当初 2020-12-07 07:37

If I have a dataframe with the following columns:

1. NAME                                     object
2. On_Time                                      object
         


        
12条回答
  •  失恋的感觉
    2020-12-07 08:03

    I use infer_objects()

    Docstring: Attempt to infer better dtypes for object columns.

    Attempts soft conversion of object-dtyped columns, leaving non-object and unconvertible columns unchanged. The inference rules are the same as during normal Series/DataFrame construction.

    df.infer_objects().dtypes

提交回复
热议问题