Print(income.dtypes)

My Code:

print(income.dtypes)

This is the result:
image

My question: How to filter/show ‘object’ only for the code above?

Thank you!

You should try:

income.select_dtypes(include=['object'])
1 Like

Thank you! @monorienaghogho This line of code will show the DataFrame of object columns only.

It works fine, but can we get the column names and their data types as the above format?
Something like this:

image

Assign to a new data frame and print the data types.

new_df = income.select_dtypes(include=['object'])
print(new_df.dtypes)
1 Like

@monorienaghogho Thank you! I really appreciate your help.
Here is the result of @monorienaghogho 's code for someone interested:

image

1 Like