-
-
Save quantra-go-algo/c2416193e9ab6bebada455f46ddace1b 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
#Convert data into numerical values with mean | |
Infected = [2, 4, 5, 6, 4, 3] | |
Predictor = ['Delta', 'Lambda', 'Omicron’, ’Lambda’, ’Delta’, ’Omicron’] | |
Infected_df = pd.DataFrame(data={'Infected':Infected, 'Predictor':Predictor}) | |
means = Infected_df.groupby('Predictor')['Infected'].mean() | |
Infected_df['Predictor_encoded'] = Infected_df['predictor'].map(means) | |
Infected_df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment