how to check datatype of column in dataframe python
df['DataFrame Column'].dtypes
how to check datatype of column in dataframe python
df['DataFrame Column'].dtypes
python: check type and ifno of a data frame
df.shape
df.info()
df.dtypes
des = df.describe() # Summary
des_num = df.describe(include=[np.number]) # Include only numerical columns
des_obj = df.describe(include=[np.object]) # Include only string columns
des_obj.transpose()
# Show list of variable / columns in DF
df.columns
# Count number of variables / columns in DF
len(df.columns)
# Count variable
df["myvar"].value_counts()
pandas show column types
# df is your pandas dataframe
df.dtypes
get columns by type pandas
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']
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us