Skip to content

Instantly share code, notes, and snippets.

@mikekeith52
Last active April 13, 2021 00:28
Show Gist options
  • Select an option

  • Save mikekeith52/cdc9cde76dccc5e8099d2e169f0f678a to your computer and use it in GitHub Desktop.

Select an option

Save mikekeith52/cdc9cde76dccc5e8099d2e169f0f678a to your computer and use it in GitHub Desktop.
data_state.fillna(method='ffill',inplace=True)
max_perc = lambda x: np.max([i/100 for i in x])
data_state_piv = pd.pivot_table(data_state,
index='location',
values=['total_vaccinations_per_hundred','people_vaccinated','people_fully_vaccinated_per_hundred','people_fully_vaccinated'],
aggfunc={'total_vaccinations_per_hundred':max_perc,
'people_fully_vaccinated_per_hundred':max_perc,
'people_vaccinated':np.max,
'people_fully_vaccinated':np.max})
data_state['date'] = pd.to_datetime(data_state['date'])
data_cumsum_doses = pd.pivot_table(data_state,
index='date',
values=['total_distributed','people_vaccinated','people_fully_vaccinated'],
aggfunc=np.sum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment