Separate columns from a dataset

Asked

Viewed 76 times

-2

I need to separate in a list the column types of a dataset in numerical and non-numerical.

For example:

def identifica_tipos(df):
    col_numerica = []
    for col in df.columns:
        if col.isnumeric:
            col_numerica.append(col)

But this function that I created does not separate the data, someone has some suggestion of functions that can do this ??

1 answer

0


Maybe so?

import numpy as np

new_df = df.select_dtypes(include=np.number)
  • works perfectly , thank you and always come back !!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.