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

Branch isa #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions DataFrame_Groupby.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
__author__ = 'Who ?'
__author__ = 'Pacome'

import pandas as pd
import numpy as np
Expand All @@ -24,8 +24,10 @@


def cloneDF(df):
return pd.DataFrame(df.values.copy(), df.index.copy(), df.columns.copy()).convert_objects(convert_numeric=True)

#return pd.DataFrame(df.values.copy(), df.index.copy(), df.columns.copy()).convert_objects(convert_numeric=True)
return pd.DataFrame(df.values.copy(),
df.index.copy(),
df.columns.copy()).infer_objects()

# Show Films with more votes. (groupby + sorted)
numberRatings = cloneDF(mergeRatings)
Expand Down Expand Up @@ -59,7 +61,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)
print('My info sorted: \n%s' % sortRatingsField[:15])
sortRatingsField_pac = cloneDF(mergeRatings)
sortRatingsField_pac = sortRatingsField_pac.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_pac[: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__ = 'Isa?'

import pandas as pd
import numpy as np
Expand Down