개발/Python

Pandas DataFrame mean(), median(), std(), var(), corr() FutureWarning

강서버 2024. 3. 26. 19:20
728x90
반응형

 

>>> import pandas as pd

>>> df1 = pd.read_csv('sample.csv')

>>> df1.mean()

<stdin>:1: FutureWarning: Dropping of nuisance columns in DataFrame reductions (with 'numeric_only=None') is deprecated; in a future version this will raise TypeError.  Select only valid columns before calling the reduction.
Eng     83.1
Math    73.7
dtype: float64

 

[ Solve ]

Select only valid columns or set numeric_only=True.

 

>>> df1.mean(numeric_only=True)

>>> df1.median(numeric_only=True)

>>> df1.std(numeric_only=True)

>>> df1.var(numeric_only=True)

>>> df1.corr(numeric_only=True)

 

or

 

>>> df1[['Eng', 'Math']].mean()

>>> df1[['Eng', 'Math']].median()

>>> df1[['Eng', 'Math']].std()

>>> df1[['Eng', 'Math']].var()

>>> df1[['Eng', 'Math']].corr()

 

 

728x90
반응형