Search code examples
pythonpandasmachine-learningdata-sciencedata-analysis

How to list of ave_rating based on PlaceID, take its average and assign to all the PlaceID's with PlaceID.?


This is the sample of my dataset (in image enter image description heree), i need each unique placeID to have only one rated value by averaging all the ratings for each placeID, i tried doing it with python and pandas as lib but it doesn't work, help needed!!

    1.


Solution

  • You can refer below code. It will take the mean of ave_rating column.Here I have assumed that for each placeID: Latitude,longitude and Rcuisine value is same.

    df.groupby(['placeID','latitude','longitude','price','Rcuisine']).mean()