<jupyter_start><jupyter_text>Importing libraries<jupyter_code>import pandas as pd<jupyter_output><empty_output><jupyter_text>Reading files<jupyter_code>results = pd.read_csv('Data/results.csv')

drivers = pd.read_csv('Data/drivers.csv', encoding='latin-1')
driverStanding = pd.read_csv('Data/driverStandings.csv')

circuits = pd.read_csv('Data/circuits.csv', encoding='latin-1')
races =  pd.read_csv('Data/races.csv')

constructors = pd.read_csv('Data/constructors.csv')
constructorResult = pd.read_csv('Data/constructorResults.csv')
constructorStanding = pd.read_csv('Data/constructorStandings.csv')

pitStops =  pd.read_csv('Data/pitStops.csv')

qualifying = pd.read_csv('Data/qualifying.csv')

weather = pd.read_csv('Data/Weather_SafetyCar.csv')<jupyter_output><empty_output><jupyter_text>Droping and renaming columns<jupyter_code>results.drop(columns=['fastestLapTime', 'fastestLap', 'time', 'positionText', 'position', 'number', 'milliseconds'], inplace=True)

drivers.drop(columns=['number', 'dob', 'nationality', 'url', 'forename', 'surname', 'code'], inplace=True)
driverStanding.drop(columns=['positionText'], inplace=True)

circuits.drop(columns=['alt', 'url', 'location', 'country', 'circuitRef'], inplace=True)
races.drop(columns=['url', 'time'], inplace=True)

constructors.drop(columns=['url', 'Unnamed: 5'], inplace=True)
constructorResult.drop(columns=['status'], inplace=True)
constructorStanding.drop(columns=['positionText', 'Unnamed: 7'], inplace=True)

pitStops.drop(columns=['time'], inplace=True)

qualifying.drop(columns=['q1', 'q2', 'q3'], inplace=True)

weather.drop(columns=['SC Laps'], inplace=True)
results.rename(columns={'points': 'points results'}, inplace=True)

driverStanding.rename(columns={'points': 'points driver standing'}, inplace=True)

circuits.rename(columns={'name': 'circuit name'}, inplace=True)
races.rename(columns={'name': 'race name'}, inplace=True)
weather.rename(columns={'name': 'race name'}, inplace=True)

constructorResult.rename(columns={'points': 'points constructor results'}, inplace=True)
constructorStanding.rename(columns={'points': 'points constructor standing',
                                    'position': 'position constructor standing',
                                    'wins': 'Wins constrcuntor standing'}, inplace=True)<jupyter_output><empty_output><jupyter_text>Merging all the files in one<jupyter_code>driver_table = pd.merge(drivers, driverStanding, on='driverId').dropna()
driver_table.drop(columns=['driverRef', 'driverStandingsId'], inplace=True)

race_circuit_table = pd.merge(pd.merge(circuits, races, on='circuitId'), weather, on=['year', 'race name']).dropna()
race_circuit_table.drop(columns=['circuit name', 'round', 'race name'], inplace=True)

constructors_table = pd.merge(pd.merge(constructors, constructorStanding, on='constructorId'), constructorResult, on=['constructorId', 'raceId']).dropna()
constructors_table.drop(columns=['constructorRef', 'name', 'nationality', 'constructorStandingsId', 'constructorResultsId'],  inplace=True)
results_driver_table = pd.merge(driver_table, results, on=['driverId', 'raceId'])

results = pd.merge(results, race_circuit_table, on='raceId')

results = pd.merge(results, constructors_table, on=['constructorId', 'raceId'])<jupyter_output><empty_output><jupyter_text>creating and sorting columns<jupyter_code>results['weather_numeric'] = results['weather'].replace({'Dry': 0, 'Wet': 1, 'Varied': 2})
results['race finished'] = results['statusId'].apply(lambda x: 0 if x == 1 else 1)
results = results[['resultId', 'raceId', 'driverId', 'constructorId', 'circuitId', 'statusId', 'grid', 'positionOrder',
                   'points results', 'laps', 'rank', 'fastestLapSpeed', 'lat', 'lng', 'date', 'year', 'weather',
                   'weather_numeric', 'points constructor standing', 'position constructor standing',
                   'Wins constrcuntor standing', 'points constructor results', 'race finished']]<jupyter_output><empty_output><jupyter_text>Exporting data to csv<jupyter_code>results.to_csv('total_data/results.csv', index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1698710148454612, 'fraction_numerical': 0.003163786809442687, 'mean_word_length': 7.7633262260127935, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '588489', 'license': 'MIT', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1321, 'n_words': 225, 'path': 'data_parser.ipynb', 'repo_name': 'jeremymolina/lead-cienciadatos-proyecto1', 'size': '4109'}