Created
December 9, 2013 18:30
-
-
Save diezguerra/7877891 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "max-min" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "import pandas as pd\nimport numpy as np", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 1 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "df = pd.DataFrame({\n 'fbid': np.random.random_integers(600000000000, 680000000000, 1000),\n 'clicks': np.random.random_integers(0, 3500, 1000)})", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 4 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "df", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": "<pre>\n<class 'pandas.core.frame.DataFrame'>\nInt64Index: 1000 entries, 0 to 999\nData columns (total 2 columns):\nclicks 1000 non-null values\nfbid 1000 non-null values\ndtypes: int64(2)\n</pre>", | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 6, | |
"text": "<class 'pandas.core.frame.DataFrame'>\nInt64Index: 1000 entries, 0 to 999\nData columns (total 2 columns):\nclicks 1000 non-null values\nfbid 1000 non-null values\ndtypes: int64(2)" | |
} | |
], | |
"prompt_number": 6 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "df.head()", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": "<div style=\"max-height:1000px;max-width:1500px;overflow:auto;\">\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>clicks</th>\n <th>fbid</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td> 1851</td>\n <td> 615576556063</td>\n </tr>\n <tr>\n <th>1</th>\n <td> 3292</td>\n <td> 659184954357</td>\n </tr>\n <tr>\n <th>2</th>\n <td> 1994</td>\n <td> 629541945052</td>\n </tr>\n <tr>\n <th>3</th>\n <td> 3285</td>\n <td> 635551117715</td>\n </tr>\n <tr>\n <th>4</th>\n <td> 3098</td>\n <td> 653395372904</td>\n </tr>\n </tbody>\n</table>\n</div>", | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 7, | |
"text": " clicks fbid\n0 1851 615576556063\n1 3292 659184954357\n2 1994 629541945052\n3 3285 635551117715\n4 3098 653395372904" | |
} | |
], | |
"prompt_number": 7 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "min_value = 1000\nmax_value = 2000", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 8 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "filtered_df = df[(df.clicks >= min_value) & (df.clicks <= max_value)]", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 18 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "filtered_df", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": "<pre>\n<class 'pandas.core.frame.DataFrame'>\nInt64Index: 290 entries, 0 to 996\nData columns (total 2 columns):\nclicks 290 non-null values\nfbid 290 non-null values\ndtypes: int64(2)\n</pre>", | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 19, | |
"text": "<class 'pandas.core.frame.DataFrame'>\nInt64Index: 290 entries, 0 to 996\nData columns (total 2 columns):\nclicks 290 non-null values\nfbid 290 non-null values\ndtypes: int64(2)" | |
} | |
], | |
"prompt_number": 19 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "filtered_df.clicks.min()", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 24, | |
"text": "1003" | |
} | |
], | |
"prompt_number": 24 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "filtered_df.clicks.max()", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 25, | |
"text": "2000" | |
} | |
], | |
"prompt_number": 25 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": "", | |
"language": "python", | |
"metadata": {}, | |
"outputs": [] | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment