datafest competition 2019
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.1 KiB

  1. import numpy as np
  2. import pandas as pd
  3. def join_cols():
  4. # Reads in csv files to be manipulated
  5. dfg = pd.read_csv('data_preparation/data/games_ranked.csv')
  6. # Creates the new dataframe where each date is a unique column, and gets the number of dates
  7. unique_dates = pd.DataFrame(dfg["Date"].unique()).to_numpy()
  8. unique_rows = unique_dates.shape[0]
  9. daily_elos = np.array(unique_rows).astype(float)
  10. print(unique_rows)
  11. # Creates two numpy arrays to perform some operations on
  12. dates = dfg["Date"].to_numpy()
  13. e_change = dfg["eloChangeAdjusted"].to_numpy()
  14. rows = dates.shape()[0]
  15. # sums up the elo change on a given day and then exports it to a unique .csv file
  16. x = 0
  17. for i in range(0, rows):
  18. if not (dates[i] == unique_dates[x]):
  19. x = x + 1
  20. daily_elos[x] = daily_elos[x] + e_change[i]
  21. # Creates a new dataframe from the two unique date array and the daily elo change array
  22. df_dec = pd.DataFrame()
  23. df_dec["Date"] = unique_dates
  24. df_dec["DailyElo"] = daily_elos
  25. print(df_dec)