Skip to content
Formula 1 2023
  • AI Chat
  • Code
  • Report
  • # Tratamiento de datos
    # ==============================================================================
    import numpy as np
    import pandas as pd
    
    # Gráficos
    # ==============================================================================
    import matplotlib.pyplot as plt
    import matplotlib.font_manager
    from matplotlib.ticker import MultipleLocator
    from matplotlib import style
    style.use('ggplot') or plt.style.use('ggplot')
    import seaborn as sns
    # Configuración warnings
    # ==============================================================================
    import warnings
    warnings.filterwarnings('ignore')
    pd.set_option('display.max_rows', 10)
    pd.set_option('display.max_columns', 10)
    df_result=pd.read_csv('results.csv',encoding='utf-8',sep=',')
    df_races=pd.read_csv('races.csv',encoding='utf-8',sep=',')
    df_drivers=pd.read_csv('drivers.csv',encoding='utf-8',sep=',')
    df_constructor=pd.read_csv('constructors.csv',encoding='utf-8',sep=',')
    df_constructor
    df_status=pd.read_csv('status.csv',encoding='utf-8',sep=',')
    df_sprint=pd.read_csv('sprint_results.csv',encoding='utf-8',sep=',')
    df_races.year=df_races.year.astype(str)
    df_races2022=df_races[df_races['year']=='2023']
    df_result['driverName']=df_result['driverId'].map(df_drivers.set_index('driverId')['surname'])
    df_races2022.tail()
    df_result['constructorName']=df_result['constructorId'].map(df_constructor.set_index('constructorId')['name'])
    df_result['statusDescription']=df_result['statusId'].map(df_status.set_index('statusId')['status'])