Skip to content

Instantly share code, notes, and snippets.

@H2CO3
Last active September 20, 2025 06:10
Show Gist options
  • Save H2CO3/c1c4557c8556cd0ae34e589bd5aee6fa to your computer and use it in GitHub Desktop.
Save H2CO3/c1c4557c8556cd0ae34e589bd5aee6fa to your computer and use it in GitHub Desktop.
import numpy as np
import pandas as pd
install = np.concatenate([np.ones(19), np.zeros(1)])
repair = np.concatenate([np.ones(19), [np.nan]])
outage = np.concatenate([np.ones(17), np.zeros(1), [np.nan, np.nan]])
df = pd.DataFrame({'install': install, 'repair': repair, 'outage': outage})
print(df)
proportions = []
for i in range(1_000_000):
indexes = np.random.choice(a=len(df), size=len(df), replace=True)
p = np.nanmean(df.iloc[indexes].to_numpy())
proportions.append(p)
proportions = np.array(proportions)
mean = np.mean(proportions)
std = np.std(proportions)
print(f'{mean=!s}, {std=!s}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment