Created
March 30, 2023 22:49
-
-
Save john-adeojo/536e0f43d278e98ebc216a50a31ce531 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# calculate per follower metrics | |
tweets_df['favorite_count_pf'] = tweets_df['favorite_count']/ tweets_df['follower_count'] | |
tweets_df['retweet_count_pf'] = tweets_df['retweet_count']/ tweets_df['follower_count'] | |
tweets_df['quote_count_pf'] = tweets_df['quote_count']/ tweets_df['follower_count'] | |
tweets_df['reply_count_pf'] = tweets_df['reply_count']/ tweets_df['follower_count'] | |
# normalise metrics | |
scaler = MinMaxScaler() | |
scaled_values = scaler.fit_transform(tweets_df[['favorite_count_pf', 'retweet_count_pf', 'quote_count_pf', 'reply_count_pf']]) | |
tweets_df[['favorite_count_pf', 'retweet_count_pf', 'quote_count_pf', 'reply_count_pf']] = scaled_values |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment