Gross Domestic Product (GDP) is a crucial economic indicator representing the total value of goods and services produced within a country over a specific period, usually a year. This project aims to analyze GDP data to gain insights into economic performance, growth rates, and comparisons between countries using Python libraries such as Pandas, Plotly, and Numpy.
-
Dataset Walkthrough:
- Understand the structure and content of the dataset.
- Use
df.head()
to display the first few rows of the dataset for an overview.
-
GDP Growth Calculation:
-
GDP growth rate is calculated using the formula:
GDP growth rate = (GDP in current period - GDP in previous period) / GDP in previous period * 100
-
For example, if GDP was 100 in 2020 and 105 in 2021, the growth rate is:
GDP growth rate = (105 - 100) / 100 * 100 = 5%
-
-
Visualization Using Plotly:
- Create interactive and dynamic graphs for better data visualization.
- Utilize
plotly.express
andplotly.graph_objects
for plotting.
-
World GDP Growth Rate Analysis:
- Visualize GDP growth trends across all countries in the dataset.
-
Country-wise GDP Comparison:
-
Compare GDP across countries to understand relative economic performance.
-
Focused comparison of GDP growth between India and China:
c1 = df[df['Country Name'] == 'China'] c2 = df[df['Country Name'] == 'India'] df_pr = pd.concat([c1, c2], axis=0) fig = px.line(df_pr, x='Year', y='Value', title='GDP Comparison | India & China', color='Country Name') pyo.plot(fig, filename='IND|CHN.html')
-
- Pandas: For data manipulation and analysis.
- Plotly: For creating interactive and visually appealing plots.
- Numpy: For numerical operations and calculations.
-
Install the required libraries:
pip install pandas plotly numpy
-
Set up Plotly account (if required) at plotly.com.
- Load the dataset using Pandas and explore its structure with
df.head()
. - Calculate GDP growth rates for the dataset using the formula provided.
- Use Plotly to create:
- Global GDP growth visualizations.
- Comparisons across countries.
- Focused comparisons between India and China.
- Save the interactive plots locally (e.g.,
IND|CHN.html
).
- Visualization of GDP trends highlights differences in economic growth across countries.
- Comparing India and China’s GDP illustrates how China’s GDP has grown significantly faster than India’s over the analyzed period.
- Interactive plots showcasing:
- Global GDP growth rates.
- Country-wise GDP comparisons.
- India vs. China GDP trends.
# Example calculation of GDP growth rate
gdp_growth_rate = (current_gdp - previous_gdp) / previous_gdp * 100
import plotly.express as px
import pandas as pd
c1 = df[df['Country Name'] == 'China']
c2 = df[df['Country Name'] == 'India']
df_pr = pd.concat([c1, c2], axis=0)
fig = px.line(df_pr, x='Year', y='Value', title='GDP Comparison | India & China', color='Country Name')
fig.show()
This project leverages Python's data analysis and visualization libraries to analyze GDP data, providing valuable insights into economic growth and inter-country comparisons. The interactive plots enable users to explore data dynamically and make informed conclusions about global and country-specific economic trends.