Skip to content

Instantly share code, notes, and snippets.

@Vernal-Inertia Vernal-Inertia/NaN-12.py

Last active Feb 13, 2019
Embed
What would you like to do?
In [24]:
original = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3] # removing NaNs
replaced_by_mean = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 1.8, 1.8, 1.8, 1.8, 1.8]
replaced_by_proportion = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 1, 1, 2, 2, 3]
plt.figure(figsize=(10,6))
plt.subplot(3, 1, 1)
plt.boxplot(original, showmeans=True, vert=False)
plt.title('original', color='green')
plt.subplot(3, 1, 2)
plt.boxplot(replaced_by_mean, showmeans=True, vert=False)
plt.title('replaced_by_mean', color='blue')
plt.subplot(3, 1, 3)
plt.boxplot(replaced_by_proportion, showmeans=True, vert=False)
plt.title('replaced_by_proportion', color='magenta')
plt.tight_layout()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.