[Solved] i have developed the program and i am facing problems in it


You can try to pivot the table. Which may give the format you require.

Considering the information you gave as as ActionsOnly.csv

userId,movieId,rating
18,9,3
32,204,4
49,2817,1
62,160438,4
70,667,5
73,1599,1
73,4441,3
73,4614,3.5
73,86142,4
95,4636,2
103,71,1
118,3769,4
150,4866,2

You wan to find out what user rated what movie out of 5.

The userId is the index column, the movieId becomes the header row and the rating is what decides the values. If there is no Value it will display NaN or Not A Number

movie_pivot = movie.pivot_table(index='userId', columns="movieId", values="rating")

To Save a file in Pandas to CSV there is a simple command to_csv

so

movie_pivot.to_csv('ActionsOnly_pivot.csv')

Will save to csv.

So the full code you need is:

import pandas as pd

movie = pd.read_csv('movies.csv')

movie_pivot = movie.pivot_table(index='userId', columns="movieId", values="rating")

movie_pivot.to_csv('movies_pivot.csv')

I also strongly recommend reading about pandas, It is surprisingly easy and logical 🙂

5

solved i have developed the program and i am facing problems in it