Search⌘ K
AI Features

Exercise: Missing Values

Explore how to handle missing values in data visualizations using Python Altair. Learn to apply the impute argument and ImputeParams function to replace missing data with average values in line charts, enhancing the clarity and accuracy of your data stories.

We'll cover the following...

Consider the following DataFrame:

Python 3.10.4
import pandas as pd
import altair as alt
import numpy as np
df = pd.DataFrame({
'x': [1,2,3,4,1,2,3,4],
'y': [1, 3,np.nan, 3,2, np.nan, 4, 4],
'z': ['orange', 'orange', 'orange', 'orange', 'apple', 'apple','apple', 'apple']
}).dropna()
print(df)
...