Created
March 31, 2023 13:37
-
-
Save woodwardtw/9f02b819c0b1e927215e974e34e1a1df to your computer and use it in GitHub Desktop.
China vs US GDP comparison from 2016-2020 generated by free version of ChatGPT in March 2023
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 pandas as pd | |
import matplotlib.pyplot as plt | |
# Create a dictionary of GDP data for the USA and China from 2016 to 2020 | |
data = { | |
'Country': ['USA', 'China'], | |
'2016': [18624475, 11233273], | |
'2017': [19542968, 12408149], | |
'2018': [20580518, 13608152], | |
'2019': [21433226, 14271038], | |
'2020': [20494100, 15063315] # Note: 2020 data for China is an estimate | |
} | |
# Convert the dictionary into a pandas DataFrame | |
df = pd.DataFrame(data) | |
# Set the Country column as the DataFrame index | |
df.set_index('Country', inplace=True) | |
# Create a bar chart of the GDP data | |
ax = df.plot(kind='bar', rot=0, figsize=(10, 6)) | |
# Set the chart title and axis labels | |
ax.set_title('GDP Comparison: USA vs China (2016-2020)') | |
ax.set_xlabel('Year') | |
ax.set_ylabel('GDP (in billions of US dollars)') | |
# Display the chart | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment