Last active
May 26, 2020 08:41
-
-
Save barrysmyth/863c014da53d561bcdf432406b7d5693 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load in sample dataset | |
df = pd.read_csv('../data/segmented_bar_graph_example_data.csv').set_index('country').fillna(0) | |
# Extract the log(deaths) | |
# Use the sorted index from weeklies to sort deaths in the same way. | |
deaths = df.loc[weeklies.index]['log_deaths'] | |
# Separate the weekly mobility drops and sort them in descending order of the sum of the | |
# the weekly drops | |
weeklies = df.drop(columns=['log_deaths'])\ | |
.assign(s=df.sum(axis=1))\ | |
.sort_values('s', ascending=False)\ | |
.drop('s', axis=1) | |
weeklies.head() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment