This is what I've written up to here:
.
.
.
# Calculations of 'age' column:
dfm_age = df['age'].mean()
print(dfm_age)
df['age'] = df['age'].apply(lambda x: 'Lower' if x <= dfm_age else 'Upper')
# Calculations of 'trestbps' column:
dfm_trestbps = df['trestbps'].mean()
print(dfm_trestbps)
df['trestbps'] = df['trestbps'].apply(lambda x: 'Lower' if x <= dfm_trestbps else 'Upper')
# Calculations of 'chol' column:
dfm_chol = df['chol'].mean()
print(dfm_chol)
df['chol'] = df['chol'].apply(lambda x: 'Lower' if x <= dfm_chol else 'Upper')
# Calculations of 'num' column:
df['num'] = df['num'].apply(lambda x: 'Positive' if x == '>50_1' else 'Negative')
# Splitting data to test and learn
My data includes 30 rows and 10 columns. I'm using python.
Aucun commentaire:
Enregistrer un commentaire