<jupyter_start><jupyter_text>Create Series from ndarray<jupyter_code>np_country = np.array(['Luxembourg','Norway','Japan','Switzerland','United States','Qatar','Iceland','Sweden',
                       'Singapore','Denmark'])
s_country = pd.Series(np_country)
print s_country<jupyter_output>0       Luxembourg
1           Norway
2            Japan
3      Switzerland
4    United States
5            Qatar
6          Iceland
7           Sweden
8        Singapore
9          Denmark
dtype: object<jupyter_text>Creae Series from dict<jupyter_code>#Evaluate countries and their corresponding gdp per capita and print them as series
dict_country_gdp = pd.Series([52056.01781,40258.80862,40034.85063,39578.07441,39170.41371,37958.23146,37691.02733,
                             36152.66676,34706.19047,33630.24604,33529.83052,30860.12808],index=['Luxembourg','Macao, China',
                             'Norway','Japan','Switzerland','Hong Kong','United States','Qatar','Iceland','Sweden',
                             'Singapore','Denmark'])
print dict_country_gdp<jupyter_output>Luxembourg       52056.01781
Macao, China     40258.80862
Norway           40034.85063
Japan            39578.07441
Switzerland      39170.41371
Hong Kong        37958.23146
United States    37691.02733
Qatar            36152.66676
Iceland          34706.19047
Sweden           33630.24604
Singapore        33529.83052
Denmark          30860.12808
dtype: float64<jupyter_text>Accessing Elements in Series<jupyter_code>#access elements in the series
dict_country_gdp[0]
#access first 5 countries from the series
dict_country_gdp[0:5]
#look up a country by name or index
dict_country_gdp.loc['United States']
#look up by position
dict_country_gdp.iloc[0]<jupyter_output><empty_output><jupyter_text>Vectorized Operations in Series<jupyter_code>#Add the series
first_vector_series = pd.Series([1,2,3,4],index=['a','b','c','d'])
second_vector_series = pd.Series([10,20,30,40],index=['a','b','c','d'])
first_vector_series + second_vector_series
second_vector_series = pd.Series([10,20,30,40],index=['a','d','b','c'])
first_vector_series + second_vector_series<jupyter_output><empty_output><jupyter_text>Another Example<jupyter_code>#now replace few indexes with new ones in second vector series
second_vector_series = pd.Series([10,20,30,40],index=['a','b','e','f'])
first_vector_series + second_vector_series<jupyter_output><empty_output><jupyter_text>Create DataFrame from Lists<jupyter_code>#last five olymnics data: place, year and number of countries participated
olympic_data_list = {'HostCity':['London','Beijing','Athens','Sydney','Atlanta'],
                    'Year':[2012,2008,2004,2000,1996],
                    'No. of Participating Countries':[205,204,201,200,197]}
df_olympic_data = pd.DataFrame(olympic_data_list)
df_olympic_data<jupyter_output><empty_output><jupyter_text>Create DataFrame from dict<jupyter_code>olympic_data_dict = {'London':{2012:205},'Beijing':{2008:204}}
df_olympic_data_dict = pd.DataFrame(olympic_data_dict)
df_olympic_data_dict<jupyter_output><empty_output><jupyter_text>View DataFrame<jupyter_code>#select by City name
df_olympic_data.HostCity
#use describe function to display the content
df_olympic_data.describe<jupyter_output><empty_output><jupyter_text>Create DataFrame from dict of Series<jupyter_code>olympic_series_participation = pd.Series([205,204,201,200,197],index =[2012,2008,2004,2000,1996])
olympic_series_country = pd.Series(['London','Beijing','Athens','Sydney','Atlanta'],index=[2012,2008,2004,2000,1996])
df_olympic_series = pd.DataFrame({'No. of Participatingf Countries':olympic_series_participation,
                                  'Host Cities':olympic_series_country})
df_olympic_series<jupyter_output><empty_output><jupyter_text>Create DataFrame from ndarray<jupyter_code>np_array = np.array([2012,2008,2004,2000,1996])
dict_ndarray = {'year':np_array}
df_ndarray = pd.DataFrame(dict_ndarray)
df_ndarray<jupyter_output><empty_output><jupyter_text>Create DataFrame from DataFrame<jupyter_code>#create dataframe from a dataframe
df_from_df = pd.DataFrame(df_olympic_series)
df_from_df<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11726462797977366, 'fraction_numerical': 0.09848302431976884, 'mean_word_length': 5.400616332819722, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '273136', 'license': 'Unlicense', 'n_tokens_mistral': 1693, 'n_tokens_neox': 1423, 'n_words': 226, 'path': 'Pandas_series.ipynb', 'repo_name': 'maharjansudhan/DS_Python', 'size': '4153'}