# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Our first notebook

# Here we are learning Python Variables and some useful methods

# ## Variables

mycal = 2 + 2
mycal

mystr = "let's do it"

mystr

mydiv = 37.0 / 3.0

mydiv

# ## types

type(mycal)

# +
#help() # to close the help press Ctrl + C and then run Ctrl + Enter
# -

# # Libraries

import pandas # library for data manipulation

# %who # to list your variables

anz = pandas.read_csv('../data/gapminder_gdp_oceania.csv')

anz

anz = pandas.read_csv('../data/gapminder_gdp_oceania.csv', index_col = 'country')

anz

# ## reading table format files using pandas

africa = pandas.read_csv('../data/gapminder_gdp_africa.csv' , index_col = "country")
europe = pandas.read_csv('../data/gapminder_gdp_europe.csv' , index_col = "country")

africa

europe

europe.shape

europe.size

europe.ndim

africa.size

anz.size

anz.values

# ## Data Frames methods
#
#     df.info()
#     df.describe()
#     df.head()
#     df.tail()
#

# %who

del mycal

# %who

africa.info() # summary information of the DataFrame

# summary statistics per numeric columns
africa.describe()

africa.gdpPercap_1952.describe()

# first n rows, by default is 5
africa.head(n = 3)

# tails displays the last n rows, last 5 by default
africa.tail(n = 4 )

# %who

americas = pandas.read_csv('../data/gapminder_gdp_americas.csv', index_col= 'country')

americas.head(n=3)

americas.head(3)

americas.tail(n = 3)

americas.describe()

processed = americas.T.tail(3).T

processed

processed.columns.format()

europe.iloc # subset a part of the dataframe using index
europe.loc # subset a part of the dataframe by name
favoritecountry = europe.loc['Belgium'] # by row name

favoritecountry

europe.gdpPercap_1952

europe.loc['Greece', 'gdpPercap_1952']


europe.loc['Iceland', 'gdpPercap_2007']

europe.loc[('Iceland','Greece'),('gdpPercap_1952','gdpPercap_2007')]

europe.loc[['Iceland','Greece'],['gdpPercap_1952','gdpPercap_2007']]

processed.to_excel('../results/processed.xlsx')

# %who

# # Plots 

# %matplotlib inline 
import matplotlib.pyplot as plt

anz.plot()

anz.T.plot()



StarcoderdataJupyterScriptsDedupFiltered