Guest User

Untitled

a guest
Feb 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. import pandas as pd
  2. from scipy.sparse import csr_matrix
  3.  
  4. #reading the csv-file
  5. #if yor csv-file has header then header=1
  6. df = pd.read_csv("filepath here", header=1)
  7.  
  8. #if no header names:
  9. df.columns = ["user_id", "group_id", "group_value"]
  10.  
  11. #handling missing values in group_value
  12. df["group_value"].fillna(df["group_value"].mean)
  13.  
  14. matrix = csr_matrix(df)
Add Comment
Please, Sign In to add comment