<jupyter_start><jupyter_text>**SE REQUIERE PRESENTAR UNA APROXIMACION ENTRE LA CALIDAD DE VIDA Y EL PIB PER CAPITA DE PAISES EN EL AÑO 2019**<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import sklearn.linear_model<jupyter_output><empty_output><jupyter_text>**Se asigna el dataset de OCDE 2019 a la variable OCDE2019**<jupyter_code>OCDE_2019 = pd.read_csv('https://raw.githubusercontent.com/danielordonezg/analisis-de-datos/main/ocde_2019.csv')
OCDE_2019.head()<jupyter_output><empty_output><jupyter_text>**DIMENSIONES DEL DATASET**<jupyter_code>OCDE_2019.shape<jupyter_output><empty_output><jupyter_text>**NOMBRES DE LAS COLUMNAS**<jupyter_code>OCDE_2019.columns<jupyter_output><empty_output><jupyter_text>**CATEGORIAS UNICAS DE LA COLUMNA INEQUALITY**<jupyter_code>OCDE_2019['INEQUALITY'].unique()<jupyter_output><empty_output><jupyter_text>**SE REQUIERE QUE EL DATASET TENGA SOLAMENTE LA CATEGORIA TOT DE LA COLUMNA INEQUIALITY**<jupyter_code>OCDE_2019 = OCDE_2019[OCDE_2019['INEQUALITY'] == 'TOT']
OCDE_2019.head()<jupyter_output><empty_output><jupyter_text>**SE REQUIERE QUE LA COLUMNA COUNTRY QUEDE COMO INDEX**<jupyter_code>OCDE_2019 = OCDE_2019.pivot(index='Country', columns='Indicator', values='Value')
OCDE_2019.head()<jupyter_output><empty_output><jupyter_text>**SE IMPORTA EL DATASET Y SE LE ASIGNA A VARIABLE GDP_2019**<jupyter_code>GDP_2019 = pd.read_csv('https://raw.githubusercontent.com/danielordonezg/analisis-de-datos/main/gdp_per_capita_2019.csv')
GDP_2019.head()<jupyter_output><empty_output><jupyter_text>**DIMENSIONES DEL DATASET**<jupyter_code>GDP_2019.shape<jupyter_output><empty_output><jupyter_text>**NOMBRE DE LAS COLUMNAS DEL DATASET**<jupyter_code>GDP_2019.columns<jupyter_output><empty_output><jupyter_text>**CAMBIAR COLUMNA 2019 POR GDP PER CAPITA Y QUE LA COLUMNA COUNTRY NAME SEA EL INDICE**<jupyter_code>GDP_2019.rename(columns={'2019 [YR2019]': 'GDP per capita'}, inplace=True)
GDP_2019.set_index('Country Name', inplace=True)
GDP_2019.head()<jupyter_output><empty_output><jupyter_text>**SE REQUIERE SABER LOS TIPOS DE DATOS DEL DATAFRAME**<jupyter_code>GDP_2019.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Index: 222 entries, Afghanistan to nan
Data columns (total 4 columns):
 #   Column          Non-Null Count  Dtype 
---  ------          --------------  ----- 
 0   Series Name     219 non-null    object
 1   Series Code     217 non-null    object
 2   Country Code    217 non-null    object
 3   GDP per capita  217 non-null    object
dtypes: object(4)
memory usage: 8.7+ KB<jupyter_text>**SE REQUIERE QUE LA COLUMNA DE GDP PER CAPITA SEA TIPO NUMERICO**<jupyter_code>GDP_2019['GDP per capita'] = GDP_2019['GDP per capita'].apply(pd.to_numeric, errors='coerce')
GDP_2019.head()<jupyter_output><empty_output><jupyter_text>**SE REQUIERE CONOCER EL TIPO DE DATO DE LA COLUMNA**<jupyter_code>GDP_2019.info()<jupyter_output><class 'pandas.core.frame.DataFrame'>
Index: 222 entries, Afghanistan to nan
Data columns (total 4 columns):
 #   Column          Non-Null Count  Dtype  
---  ------          --------------  -----  
 0   Series Name     219 non-null    object 
 1   Series Code     217 non-null    object 
 2   Country Code    217 non-null    object 
 3   GDP per capita  186 non-null    float64
dtypes: float64(1), object(3)
memory usage: 8.7+ KB<jupyter_text>**SE REQUIERE QUE LA COLUMNA GDP PER CAPITAL TENGA UNICAMENTE 3 DECIMALES**<jupyter_code>decimales = 3
GDP_2019['GDP per capita'] = GDP_2019['GDP per capita'].apply(lambda x: round(x, decimales))
GDP_2019.head()<jupyter_output><empty_output><jupyter_text>**SE REQUIERE ELIMINAR LOS DATOS DESAPARECIDOS**<jupyter_code>GDP_2019.dropna(inplace=True)
GDP_2019.isna().sum()<jupyter_output><empty_output><jupyter_text>**SE REQUIEREN LAS PRIMERAS 5 FILAS**<jupyter_code>GDP_2019.head()<jupyter_output><empty_output><jupyter_text>**SE REQUIERE FUSIONARL DATASET OCDE CON EL DATASET GDP CONSERVANDO SUS INDICES ORDENANDOLOS DE MAYOR A MENOR POR GDP**<jupyter_code>full_dataset = pd.merge(left=OCDE_2019, right=GDP_2019, left_index=True, right_index=True)
full_dataset.sort_values('GDP per capita', ascending=False, inplace=True)
full_dataset.head()<jupyter_output><empty_output><jupyter_text>**SE REQUIEREN LOS NOMBRES DE LAS COLUMNAS**<jupyter_code>full_dataset.columns
full_dataset = full_dataset[['GDP per capita', 'Life satisfaction']]
full_dataset.head()<jupyter_output><empty_output><jupyter_text>**SE MUESTRAN LOS DATOS ESTADISTICOS DEL DATAFRAME**<jupyter_code>full_dataset.describe().T<jupyter_output><empty_output><jupyter_text>**SE REQUIERE PREPARAR Y VISUALIZAR LOS DATOS DE 'GDP PER CAPITA' VS 'LIFE SATISFACTION'**<jupyter_code>X = np.c_[full_dataset['GDP per capita']]
y = np.c_[full_dataset['Life satisfaction']]

full_dataset.plot(kind='scatter', x='GDP per capita', y = 'Life satisfaction')
plt.show()<jupyter_output><empty_output><jupyter_text>**SE REQUIERE SABER CUAL ES LA SATISFACCION DE VIDA EN COLOMBIA**<jupyter_code>full_dataset[['GDP per capita', 'Life satisfaction']].loc['Colombia']<jupyter_output><empty_output><jupyter_text>**SE REQUIERE SABER CUAL ES LA SATISFACCION DE VIDA EN FRANCIA**<jupyter_code>full_dataset[['GDP per capita', 'Life satisfaction']].loc['France']<jupyter_output><empty_output><jupyter_text>**SE REQUIERE GRAFICAR LOS DATOS DE GDP PER CAPITA EN RELACION A LIFE SATISFACTION**<jupyter_code>full_dataset.plot(kind='scatter', x='GDP per capita', y = 'Life satisfaction', figsize=(10,6))
plt.title('GDP per capita vs Life Satisfaction')
plt.show()<jupyter_output><empty_output><jupyter_text>**SE REQUIERE MOSTRAR LOS DATOS DE LOS PAISES (LUXEMBURGO,COLOMBIA,FRANCE,HUNGARY,NORWAY)**<jupyter_code>full_dataset.plot(kind='scatter', x='GDP per capita', y = 'Life satisfaction', figsize=(10,6))
texto_paises = {'Luxembourg': (105000, 6.3), 
                'Colombia':   (7000, 5.8),
                'France':     (45000, 6.0),
                'Hungary':    (19000, 5.0),
                'Norway':     (80000, 7.0)}

for country, pos_text in texto_paises.items():
  pos_x, pos_y = full_dataset.loc[country]
  plt.annotate(country, xy=(pos_x, pos_y), xytext=pos_text, 
               arrowprops=dict(facecolor='black', width=0.8, headwidth=5, shrink=0.1))
  plt.plot(pos_x, pos_y, 'ro') 

plt.title('GDP per capita vs Life Satisfaction')
plt.show()<jupyter_output><empty_output><jupyter_text>**SE REQUIERE OBTENER INFORMACION DE LOS PAISES PRESENTES EN EL GRAFICO**<jupyter_code>full_dataset.loc[list(texto_paises.keys())]<jupyter_output><empty_output><jupyter_text>**TRAZAR LINEA RECTAY=0.00005xX+0**<jupyter_code>full_dataset.plot(kind='scatter', x='GDP per capita', y = 'Life satisfaction', figsize=(10,6))
plt.title('GDP per capita vs Life Satisfaction')
x = np.linspace(0, 120000)

plt.plot(x, 0.00005*x+0, 'r')
plt.text(60000, 2, '$y=0.00005x+0$', fontsize=14, color='r')
plt.text(60000, 1.6, '$m=5*10^-5$', fontsize=14, color='r')
plt.text(60000, 1.3, '$b=0$', fontsize=14, color='r')


plt.show()<jupyter_output><empty_output><jupyter_text>**NOTEBOOK CON 3 LINEAS RECTAS ADICIONALES**<jupyter_code>full_dataset.plot(kind='scatter', x='GDP per capita', y = 'Life satisfaction', figsize=(10,6))
plt.title('GDP per capita vs Life Satisfaction')
x = np.linspace(0, 120000)

plt.plot(x, 0.00002*x+6, 'r')


plt.show()
full_dataset.plot(kind='scatter', x='GDP per capita', y = 'Life satisfaction', figsize=(10,6))
plt.title('GDP per capita vs Life Satisfaction')
x = np.linspace(0, 120000)

plt.plot(x, 0.00003*x+5, 'r')


plt.show()
full_dataset.plot(kind='scatter', x='GDP per capita', y = 'Life satisfaction', figsize=(10,6))
plt.title('GDP per capita vs Life Satisfaction')
x = np.linspace(0, 120000)

plt.plot(x, 0.00005*x+4, 'r')


plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14092837855214094, 'fraction_numerical': 0.048604860486048604, 'mean_word_length': 6.351606805293006, 'pattern_counts': {'":': 0, '<': 113, '<?xml version=': 0, '>': 113, 'https://': 2, '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': '28', 'dir': 'jupyter-structured-clean-dedup', 'id': '99497', 'license': 'MIT', 'n_tokens_mistral': 3463, 'n_tokens_neox': 3056, 'n_words': 590, 'path': 'EDA.ipynb', 'repo_name': 'danielordonezg/Machine-Learning-Algorithms', 'size': '7777'}