Stat na_rm Checks

Small examples for checking na_rm handling in selected stats.

In [1]:
import numpy as np
import pandas as pd

from lets_plot import *

LetsPlot.setup_html()
In [2]:
df_x = pd.DataFrame({
    "x": [1, 2, np.nan, 4, 5, np.nan]
})

df_xy = pd.DataFrame({
    "x": [1, 2, np.nan, 4, 5, np.nan],
    "y": [2, np.nan, 3, 4, 5, np.nan],
    "g": ["A", "A", "A", "B", "B", "B"]
})

stat_summary

In [3]:
ggplot(df_xy, aes("g", "y")) + stat_summary()
Out[3]:
In [4]:
ggplot(df_xy, aes("g", "y")) + stat_summary(na_rm=True)
Out[4]:

stat_summary_bin

In [5]:
ggplot(df_xy, aes("x", "y")) + stat_summary_bin(bins=3)
Out[5]:
In [6]:
ggplot(df_xy, aes("x", "y")) + stat_summary_bin(bins=3, na_rm=True)
Out[6]:

stat_ecdf

In [7]:
ggplot(df_x, aes("x")) + stat_ecdf()
Out[7]:
In [8]:
ggplot(df_x, aes("x")) + stat_ecdf(na_rm=True)
Out[8]:

stat_sum

In [9]:
ggplot(df_xy, aes("x", "y")) + stat_sum()
Out[9]:
In [10]:
ggplot(df_xy, aes("x", "y")) + stat_sum(na_rm=True)
Out[10]: