May-02-2020, 12:31 PM
Hi,
I want to calculate column mean and row mean & skip "na" and "non-numeric". I use below code, but it gives some warning as show below:
__main__:5: FutureWarning: convert_objects is deprecated. Use the data-type specific converters pd.to_datetime, pd.to_timedelta and pd.to_numeric.
I want to calculate column mean and row mean & skip "na" and "non-numeric". I use below code, but it gives some warning as show below:
__main__:5: FutureWarning: convert_objects is deprecated. Use the data-type specific converters pd.to_datetime, pd.to_timedelta and pd.to_numeric.
import pandas as pd df = pd.read_csv(r"D:\Data\PythonCodes\outsummary2.csv") print((df[['s2']].convert_objects(convert_numeric=True)).mean(skipna=True))my csv data:
s1 s2 s3 A 1 2 1 B na 5 3 U 1 na 0 Z 0 Z 0 2 2is there any efficient way to skip "non-numeric" and "na", while calculating column mean (or sum)