# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: 'Python 3.9.5 64-bit (''.venv'': venv)'
#     language: python
#     name: python3
# ---

# +
import pandas as pd

df = pd.read_excel('dataset for dealing missing data/dummy_data.xlsx', index_col=0)
df
# -

df.fillna(0)

df

# +
# backward fill

df.bfill()

# +
# forward fill

df.ffill()

# +
# mean

mean_age = df['Age'].mean()
print(mean_age)
# -

mean_height = df['Height(cm)'].mean()
print(mean_height)

df['Age'].fillna(mean_age)

df = pd.read_csv('dataset for dealing missing data/dummy_age_weight.csv')
df

for x in df.groupby('Gender'):
    print('Printing group')
    print(x)
    print(x[1].mean())
    print()

df['Weight(kg)'] = df.groupby('Gender').transform(lambda x: x.fillna(x.mean()))
df['Weight(kg)']

StarcoderdataJupyterScriptsDedupFiltered