Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. import seaborn as sns
  2. import pandas as pd
  3. import matplotlib.pyplot as plt
  4. import numpy as np
  5.  
  6.  
  7. df_in = pd.DataFrame(None)
  8. with open('input/b_read_on.txt') as file:
  9. file_r = []
  10. for line in file.readlines():
  11. file_r.append([int(x.strip('\n')) for x in line.split(' ') if x and x is not ' ' and x is not '\n'])
  12. num_books = int(file_r[0][0])
  13. num_libraries = int(file_r[0][1])
  14. days_scanning = int(file_r[0][2])
  15.  
  16. book_score = file_r[1]
  17.  
  18.  
  19. df_in = pd.DataFrame(index=np.arange(0, num_libraries), columns=['signup', 'shipping', 'books', 'score'])
  20.  
  21. index = 0
  22. first = True
  23. for rows in file_r[2:]:
  24. if first:
  25. df_in.loc[index, 'signup'] = rows[1]
  26. df_in.loc[index, 'shipping'] = rows[2]
  27. first = False
  28. else:
  29. df_in.loc[index, 'books'] = np.array(rows)
  30. df_in.loc[index, 'score'] = np.array([book_score[i] for i in rows])
  31.  
  32. index += 1
  33. first = True
  34.  
  35.  
  36. df_in.head()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement