Answers for "found features with object datatype"

1

found features with object datatype

In [2]: df = pd.DataFrame({'NAME': list('abcdef'),
    'On_Time': [True, False] * 3,
    'On_Budget': [False, True] * 3})

In [3]: df.select_dtypes(include=['bool'])
Out[3]:
  On_Budget On_Time
0     False    True
1      True   False
2     False    True
3      True   False
4     False    True
5      True   False

In [4]: mylist = list(df.select_dtypes(include=['bool']).columns)

In [5]: mylist
Out[5]: ['On_Budget', 'On_Time']
Posted by: Guest on November-23-2020
0

found features with object datatype

cols = [c for c in df.columns if df[c].dtype in ['object', 'datetime64[ns]']]
Posted by: Guest on August-18-2021

Browse Popular Code Answers by Language