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.

61 lines
1.9 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. import pandas as pd
  2. import numpy as np
  3. def vectorize_mult(column, dictionary, postfix, df, file=None):
  4. newCol = column + postfix
  5. df[newCol] = df[column].map(dictionary)
  6. if file is not None:
  7. df.to_csv('cleaned/{}.csv'.format(file))
  8. csv = pd.read_csv("data/rpe.csv")
  9. training = csv["Training"].unique()
  10. session = csv["SessionType"].unique()
  11. boms = csv["BestOutOfMyself"].unique()
  12. print(training)
  13. print(session)
  14. print(boms)
  15. vectorize_mult("Training", {"No": 0, "Yes": 1}, "", csv)
  16. mapping = {"Mobility/Recovery": 1, "Game": 0, "Skills": 0, "Conditioning": 0,
  17. "Strength": 0, "Combat": 0, "Speed": 0, np.nan: 0}
  18. vectorize_mult("SessionType", mapping, "Mobility/Recovery", csv)
  19. mapping["Mobility/Recovery"] = 0
  20. mapping["Game"] = 1
  21. vectorize_mult("SessionType", mapping, "Game", csv)
  22. mapping["Game"] = 0
  23. mapping["Skills"] = 1
  24. vectorize_mult("SessionType", mapping, "Skills", csv)
  25. mapping["Skills"] = 0
  26. mapping["Conditioning"] = 1
  27. vectorize_mult("SessionType", mapping, "Conditioning", csv)
  28. mapping["Conditioning"] = 0
  29. mapping["Strength"] = 1
  30. vectorize_mult("SessionType", mapping, "Strength", csv)
  31. mapping["Strength"] = 0
  32. mapping["Combat"] = 1
  33. vectorize_mult("SessionType", mapping, "Combat", csv)
  34. mapping["Combat"] = 0
  35. mapping["Speed"] = 1
  36. vectorize_mult("SessionType", mapping, "Speed", csv)
  37. mapping["Speed"] = 0
  38. mapping[np.nan] = 1
  39. vectorize_mult("SessionType", mapping, "Unknown", csv)
  40. mapping[np.nan] = 0
  41. mapping = {"Not at all": 1, "Absolutely": 0, "Somewhat": 0, np.nan: 0}
  42. vectorize_mult("BestOutOfMyself", mapping, "NotAtAll", csv)
  43. mapping["Not at all"] = 0
  44. mapping["Absolutely"] = 1
  45. vectorize_mult("BestOutOfMyself", mapping, "Absolutely", csv)
  46. mapping["Absolutely"] = 0
  47. mapping["Somewhat"] = 1
  48. vectorize_mult('BestOutOfMyself', mapping, "Somewhat", csv)
  49. mapping["Somewhat"] = 0
  50. mapping[np.nan] = 1
  51. vectorize_mult('BestOutOfMyself', mapping, "Unknown", csv)
  52. mapping[np.nan] = 0
  53. print(csv.isnull().sum*())
  54. csv.to_csv("cleaned/notnormalized_clean_rpe.csv")