dfnew = df.select_dtypes(include=np.number)
import pandas as pd
df = pd.DataFrame({"pear": [1,2,3], "apple": [2,3,4], "orange": [3,4,5]})
len(df.columns)
3
dfnew = df._get_numeric_data()
# PANDAS: get column number from colomn name
dataframe.columns.get_loc("<col_name>")
### first method ###
len(df.columns)
### second method ###
df.shape[1]
dfName.select_dtypes(exclude=['object']).columns.tolist()
df.columns
len(df.columns)
In [45]: df = DataFrame({"pear": [1,2,3], "apple": [2,3,4], "orange": [3,4,5]})
In [46]: df.columns
Out[46]: Index([apple, orange, pear], dtype=object)
In [47]: df.columns.get_loc("pear")
Out[47]: 2
df.shape[1]