Created
April 27, 2019 10:25
-
-
Save this-is-richard/4e3e7b5b32b65d32bcee54366da3cf14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# timeseries data | |
df[col] = df[col].interpolate | |
# independent feats, numerical label | |
df.dropna(how='any', inplace=True) | |
# categorical feats | |
groupby_label = df.groupby(label) | |
print(groupby_label.mean()) | |
print(df.mean()) | |
if the_means_are_label_dependent: | |
# use group level average to fill na | |
df[feat1] = groupby_label[feat1].transform(lambda x: x.fillna(x.mean())) | |
df[feat2] = groupby_label[feat2].transform(lambda x: x.fillna(x.mean())) | |
df[feat3] = groupby_label[feat3].transform(lambda x: x.fillna(x.mean())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment