Created
August 31, 2023 16:40
-
-
Save 18182324/87d1b077a8e83620cde0ac667f4421f7 to your computer and use it in GitHub Desktop.
Comparing GDP Values of BRICS Nations Using Quandl
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
# Import necessary libraries | |
import quandl | |
import matplotlib.pyplot as plt | |
# Set your Quandl API key (you need to sign up on Quandl's website to get your API key) | |
quandl.ApiConfig.api_key = 'YOUR_API_KEY' | |
# Define the dataset codes for the BRICS nations' GDP | |
brics_gdp_datasets = { | |
'Brazil': 'ODA/BRA_NGDPD', | |
'Russia': 'ODA/RUS_NGDPD', | |
'India': 'ODA/IND_NGDPD', | |
'China': 'ODA/CHN_NGDPD', | |
'South Africa': 'ODA/ZAF_NGDPD' | |
} | |
# Define the date range for the past 15 years | |
end_date = '2023-08-31' # Replace with the desired end date | |
# Initialize an empty dictionary to store GDP data for each BRICS nation | |
gdp_data = {} | |
# Fetch GDP data for each BRICS nation and store it in the 'gdp_data' dictionary | |
for country, dataset_code in brics_gdp_datasets.items(): | |
data = quandl.get(dataset_code, end_date=end_date) | |
gdp_data[country] = data | |
# Plot the GDP data for BRICS nations | |
plt.figure(figsize=(12, 6)) | |
for country, gdp in gdp_data.items(): | |
plt.plot(gdp.index, gdp['Value'], label=country) | |
# Customize the plot | |
plt.title('GDP Comparison of BRICS Nations (Last 15 Years)') | |
plt.xlabel('Year') | |
plt.ylabel('GDP (Current US$)') | |
plt.legend() | |
plt.grid(True) | |
# Show the plot | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment