Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- from scipy.sparse import csr_matrix
- #reading the csv-file
- #if yor csv-file has header then header=1
- df = pd.read_csv("filepath here", header=1)
- #if no header names:
- df.columns = ["user_id", "group_id", "group_value"]
- #handling missing values in group_value
- df["group_value"].fillna(df["group_value"].mean)
- matrix = csr_matrix(df)
Add Comment
Please, Sign In to add comment