<jupyter_start><jupyter_text>Time Series and Line Charts can help manage misinterpretation.IF the total sales of a product is more for males, it does not necessarily mean that the product is usually brought more often by males. It might be that on one particular day the number of purchases by male was more. To get a better view of our hypothesys, it is better that we plot it using time series and line charts. It will help us get a better view of our hypothesis.  Problem : Compare GDP Per Capita Growth in the U.S. and China<jupyter_code>from matplotlib import pyplot as plt
import pandas as pd


data = pd.read_csv('countries.csv')
data.head()
#select data for US
us = data[data.country == 'United States']
us.head()
plt.plot(us.year, us.gdpPerCapita)
plt.xlabel('Year')
plt.ylabel('GDP Per Capita')
plt.title('GDP Per Capita Growth in US')
plt.show()
# select data for China
china = data[data.country == 'China']
china.head()
plt.plot(china.year, china.gdpPerCapita)
plt.xlabel('year')
plt.ylabel('gdpPerCapita')
plt.title('GDP per Capita of China over the years')
plt.show()
# show both the country's GDp Per Capita together
plt.plot(us.year, us.gdpPerCapita)
plt.plot(china.year, china.gdpPerCapita)
plt.xlabel('Year')
plt.ylabel('GDP Per Capita')
plt.title('GDP Per Capita Growth in US and China')
plt.legend(['GDP Per Capita in US', 'GDP Per Capita in China'])
plt.show()<jupyter_output><empty_output><jupyter_text>From this graph we can see how the GDP Per Capita has grown in both US and China but it is hard to know which one has grown faster on a relative term because the absolute values are so different. What if we instead compare the growth?For this let us set the GDp per Capita in the first available year to 100 and compare how it has grown in US and China wrt the year.So we need to divide the GDP per capita by the first year's GDP per Capita and multiply by 100.<jupyter_code>us.gdpPerCapita.iloc[0] # panda series's first value.
us_growth = us.gdpPerCapita / us.gdpPerCapita.iloc[0] * 100
china_growth = china.gdpPerCapita / china.gdpPerCapita.iloc[0] * 100

plt.plot(us.year, us_growth)
plt.plot(china.year, china_growth)
plt.xlabel('Year')
plt.ylabel('GDP Per Capita growth')
plt.title('GDP Per Capita Growth in US and China (first Year = 100)')
plt.legend(['GDP Per Capita growth in US', 'GDP Per Capita growth in China'])
plt.show()<jupyter_output><empty_output><jupyter_text>This graph clearly shows that the GDP Per Capita in China has grown much faster than the GDP per Capita in US (relatively)<jupyter_code><jupyter_output><empty_output><jupyter_text>Compare Polulation Growth in US and Chinaus ethe population column in the countries.csv datatry comparing both the absolute numbers and the relative growthHint : Divide the population by 1 million (10^6) so that we can get the number in millions instead.<jupyter_code><jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08498092265001735, 'fraction_numerical': 0.007630939993062782, 'mean_word_length': 5.17558886509636, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '122983', 'license': 'MIT', 'n_tokens_mistral': 973, 'n_tokens_neox': 903, 'n_words': 382, 'path': 'visualization/TimeSeries_LineCharts.ipynb', 'repo_name': 'dipbanik/AIML-Training', 'size': '2883'}