Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import seaborn as sns
- import pandas as pd
- import matplotlib.pyplot as plt
- import numpy as np
- df_in = pd.DataFrame(None)
- with open('input/b_read_on.txt') as file:
- file_r = []
- for line in file.readlines():
- file_r.append([int(x.strip('\n')) for x in line.split(' ') if x and x is not ' ' and x is not '\n'])
- num_books = int(file_r[0][0])
- num_libraries = int(file_r[0][1])
- days_scanning = int(file_r[0][2])
- book_score = file_r[1]
- df_in = pd.DataFrame(index=np.arange(0, num_libraries), columns=['signup', 'shipping', 'books', 'score'])
- index = 0
- first = True
- for rows in file_r[2:]:
- if first:
- df_in.loc[index, 'signup'] = rows[1]
- df_in.loc[index, 'shipping'] = rows[2]
- first = False
- else:
- df_in.loc[index, 'books'] = np.array(rows)
- df_in.loc[index, 'score'] = np.array([book_score[i] for i in rows])
- index += 1
- first = True
- df_in.head()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement