-
Notifications
You must be signed in to change notification settings - Fork 7
Relationship between browser and average revenue #59
base: master
Are you sure you want to change the base?
Changes from 1 commit
9c38088
90f42ec
5c57097
e4567be
cf77401
108b4e6
ec7be80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,3 +56,19 @@ def find_most_common_traffic_sources(dataset,num=5): | |
|
|
||
| """ | ||
| return dataset.train['trafficSource.source'].value_counts().head(num) | ||
|
|
||
| def find_device_revenue_relationship(dataset): | ||
| """ Find the relationship between device browser and customer revenue | ||
|
|
||
| args: | ||
| dataset (Dataset): the google analytics dataset | ||
| returns: | ||
| the name of each browser, and the average of revenue by each browser | ||
| """ | ||
| train_df = dataset.train | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do a shallow copy when you access the data. Otherwise, the line below will add "revenue" to the dataframe object and it could affect other code. |
||
| train_df['revenue'] = train_df['totals.transactionRevenue'].astype(float).fillna(0) | ||
| grouped_customer = train_df.groupby('device.browser')['revenue'].mean()/10000 | ||
| grouped_browser = train_df.groupby('device.browser')['device.browser'].unique() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Optional) consider sorting by average revenue for more consistent results. |
||
| grouped_browser = [j[0] for j in grouped_browser] | ||
| values = [i for i in grouped_customer] | ||
| return grouped_browser, values | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add 2 blank lines after here.