Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Movie lens #5

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
8 changes: 4 additions & 4 deletions DataFrame_Groupby.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
__author__ = 'Who ?'
__author__ = 'Kevin'

import pandas as pd
import numpy as np
Expand Down Expand Up @@ -59,7 +59,7 @@ def cloneDF(df):


# Sort data ratings by created field (groupby + lambda function + sorted)
sortRatingsField = cloneDF(mergeRatings)
sortRatingsField = sortRatingsField.groupby(['movie_id', 'title'])['rating'].agg(
{'COUNT': np.size, 'myAVG': lambda x: x.sum() / float(x.count())}).sort('COUNT', ascending=False)
Hamtaro = cloneDF(mergeRatings)
Hamtaro = sortRatingsField.groupby(['movie_id', 'title'])['rating'].agg(
{'COUNT': np.size, 'myAVG': lambda x: x.sum() / float(x.count())}).sort_values('COUNT', ascending=False)
print('My info sorted: \n%s' % sortRatingsField[:15])
2 changes: 1 addition & 1 deletion DataFrame_pivot_table.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
__author__ = 'Who ?'
__author__ = 'Louis'

import pandas as pd
import numpy as np
Expand Down
3 changes: 2 additions & 1 deletion Example_MovieLens.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
__author__ = 'Who ?'
__author__ = 'Luciana'

import pandas as pd

Expand Down Expand Up @@ -46,3 +46,4 @@
# Example 4: show specific columns
ratings_info = merge_ratings[['user_id', 'title', 'rating']]
print('Show specific columns: \n%s' % ratings_info[:10])

2 changes: 1 addition & 1 deletion Series_vs_DataFrame.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
__author__ = 'Who ?'
__author__ = 'Mathieu'

import pandas as pd

Expand Down