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
# Initialize Empty Container | |
engagement_list = [] | |
impressions_list = [] | |
reach_list = [] | |
saved_list = [] | |
# Loop Over Insights to Fill Container | |
for insight in media_insight: | |
engagement_list.append(insight[0]['values'][0]['value']) | |
impressions_list.append(insight[1]['values'][0]['value']) |
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
df_complete = pd.concat([df, df_media_insight], axis=1) | |
df_complete.head() |
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
# Define URL | |
url = params['endpoint_base'] + params['instagram_account_id'] + '/insights' | |
# Define Endpoint Parameters | |
endpointParams = dict() | |
endpointParams['metric'] = 'audience_city,audience_country,audience_gender_age' | |
endpointParams['period'] = 'lifetime' | |
endpointParams['access_token'] = params['access_token'] | |
# Requests Data |
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
# Create DataFrame - Audience by City | |
df_audience_city = pd.Series(audience_city, name='Count') | |
df_audience_city.index.name = 'City' | |
df_audience_city = df_audience_city.sort_values(ascending=False).reset_index() | |
df_audience_city | |
# Create DataFrame - Audience by Country | |
df_audience_country = pd.Series(audience_country, name='Count') | |
df_audience_country.index.name = 'Country' | |
df_audience_country = df_audience_country.sort_values(ascending=False).reset_index() |
OlderNewer