Skip to content

Commit

Permalink
Adicionar codigo para mestrar COI e FIFA
Browse files Browse the repository at this point in the history
  • Loading branch information
Winzen committed Jul 23, 2024
1 parent 5b65f8c commit c77fd65
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pandas as pd
import os

# Antigo arquivo de pais sem COI e FIFA
original = pd.read_csv("https://storage.googleapis.com/basedosdados/staging/br_bd_diretorios_mundo/pais/pais.csv")

html = 'https://pt.wikipedia.org/wiki/Compara%C3%A7%C3%A3o_entre_c%C3%B3digos_de_pa%C3%ADses_COI,_FIFA,_e_ISO_3166'

attrs = {'class': 'wikitable'}

dfs = pd.read_html(html, attrs=attrs, header=0)

df_dif = pd.concat([df for df in dfs])

ico_fifa = df_dif[["COI", "FIFA", "ISO-3"]]
ico_fifa.columns = ["sigla_pais_coi", "sigla_pais_fifa", "sigla_pais_iso3"]

merge_df = original.merge(ico_fifa, left_on="sigla_pais_iso3", right_on='sigla_pais_iso3', how="left")

os.makedirs("output", exist_ok=True)

merge_df.to_csv("output/pais.csv", index=False)

0 comments on commit c77fd65

Please sign in to comment.