-
-
Save raghothams/b1fee2bcaf3b1bdd27b4 to your computer and use it in GitHub Desktop.
tmp1
This file contains hidden or 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
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 7, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "import pymongo\n", | |
| "import pandas as pd" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 8, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "db = pymongo.MongoClient().instamag" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 9, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "cur = db.weekly.find({'calendar_week':30})\n", | |
| "data = cur.next()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 10, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "import pandas as pd" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 11, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "ddf = pd.DataFrame(data['images'])" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 12, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>filter</th>\n", | |
| " <th>link</th>\n", | |
| " <th>number_likes</th>\n", | |
| " <th>score</th>\n", | |
| " <th>user_id</th>\n", | |
| " <th>user_name</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>0</th>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xaf1...</td>\n", | |
| " <td>99</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1</th>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xaf1...</td>\n", | |
| " <td>127</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xfp1...</td>\n", | |
| " <td>85</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>3</th>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xfa1...</td>\n", | |
| " <td>148</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>4</th>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xfa1...</td>\n", | |
| " <td>129</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " filter link number_likes \\\n", | |
| "0 Normal https://scontent.cdninstagram.com/hphotos-xaf1... 99 \n", | |
| "1 Normal https://scontent.cdninstagram.com/hphotos-xaf1... 127 \n", | |
| "2 Normal https://scontent.cdninstagram.com/hphotos-xfp1... 85 \n", | |
| "3 Normal https://scontent.cdninstagram.com/hphotos-xfa1... 148 \n", | |
| "4 Normal https://scontent.cdninstagram.com/hphotos-xfa1... 129 \n", | |
| "\n", | |
| " score user_id user_name \n", | |
| "0 -99 348548712 agarchaa \n", | |
| "1 -99 348548712 agarchaa \n", | |
| "2 -99 348548712 agarchaa \n", | |
| "3 -99 348548712 agarchaa \n", | |
| "4 -99 348548712 agarchaa " | |
| ] | |
| }, | |
| "execution_count": 12, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "ddf.head()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 13, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "filter object\n", | |
| "link object\n", | |
| "number_likes int64\n", | |
| "score float64\n", | |
| "user_id int64\n", | |
| "user_name object\n", | |
| "dtype: object" | |
| ] | |
| }, | |
| "execution_count": 13, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "ddf.dtypes" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 14, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "import numpy as np" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 15, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "user_data = db.user.find({'calendar_week':30},{'users':True}).next()['users']" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 16, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "user_df = pd.DataFrame(user_data)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 17, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>filter</th>\n", | |
| " <th>link</th>\n", | |
| " <th>number_likes</th>\n", | |
| " <th>score</th>\n", | |
| " <th>user_id</th>\n", | |
| " <th>user_name</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>0</th>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xaf1...</td>\n", | |
| " <td>99</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1</th>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xaf1...</td>\n", | |
| " <td>127</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xfp1...</td>\n", | |
| " <td>85</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>3</th>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xfa1...</td>\n", | |
| " <td>148</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>4</th>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xfa1...</td>\n", | |
| " <td>129</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " filter link number_likes \\\n", | |
| "0 Normal https://scontent.cdninstagram.com/hphotos-xaf1... 99 \n", | |
| "1 Normal https://scontent.cdninstagram.com/hphotos-xaf1... 127 \n", | |
| "2 Normal https://scontent.cdninstagram.com/hphotos-xfp1... 85 \n", | |
| "3 Normal https://scontent.cdninstagram.com/hphotos-xfa1... 148 \n", | |
| "4 Normal https://scontent.cdninstagram.com/hphotos-xfa1... 129 \n", | |
| "\n", | |
| " score user_id user_name \n", | |
| "0 -99 348548712 agarchaa \n", | |
| "1 -99 348548712 agarchaa \n", | |
| "2 -99 348548712 agarchaa \n", | |
| "3 -99 348548712 agarchaa \n", | |
| "4 -99 348548712 agarchaa " | |
| ] | |
| }, | |
| "execution_count": 17, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "ddf.head()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 18, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>followers</th>\n", | |
| " <th>user_id</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>0</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1</th>\n", | |
| " <td>3540</td>\n", | |
| " <td>182142054</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>302687</td>\n", | |
| " <td>6166093</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>3</th>\n", | |
| " <td>1360</td>\n", | |
| " <td>33959880</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>4</th>\n", | |
| " <td>11791</td>\n", | |
| " <td>489221579</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " followers user_id\n", | |
| "0 2078 348548712\n", | |
| "1 3540 182142054\n", | |
| "2 302687 6166093\n", | |
| "3 1360 33959880\n", | |
| "4 11791 489221579" | |
| ] | |
| }, | |
| "execution_count": 18, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "user_df.head()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 19, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "final_df = user_df.merge(ddf, how='left')" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 20, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>followers</th>\n", | |
| " <th>user_id</th>\n", | |
| " <th>filter</th>\n", | |
| " <th>link</th>\n", | |
| " <th>number_likes</th>\n", | |
| " <th>score</th>\n", | |
| " <th>user_name</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>0</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xaf1...</td>\n", | |
| " <td>99</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xaf1...</td>\n", | |
| " <td>127</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xfp1...</td>\n", | |
| " <td>85</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>3</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xfa1...</td>\n", | |
| " <td>148</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>4</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xfa1...</td>\n", | |
| " <td>129</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " followers user_id filter \\\n", | |
| "0 2078 348548712 Normal \n", | |
| "1 2078 348548712 Normal \n", | |
| "2 2078 348548712 Normal \n", | |
| "3 2078 348548712 Normal \n", | |
| "4 2078 348548712 Normal \n", | |
| "\n", | |
| " link number_likes score \\\n", | |
| "0 https://scontent.cdninstagram.com/hphotos-xaf1... 99 -99 \n", | |
| "1 https://scontent.cdninstagram.com/hphotos-xaf1... 127 -99 \n", | |
| "2 https://scontent.cdninstagram.com/hphotos-xfp1... 85 -99 \n", | |
| "3 https://scontent.cdninstagram.com/hphotos-xfa1... 148 -99 \n", | |
| "4 https://scontent.cdninstagram.com/hphotos-xfa1... 129 -99 \n", | |
| "\n", | |
| " user_name \n", | |
| "0 agarchaa \n", | |
| "1 agarchaa \n", | |
| "2 agarchaa \n", | |
| "3 agarchaa \n", | |
| "4 agarchaa " | |
| ] | |
| }, | |
| "execution_count": 20, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "final_df.head()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 21, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "final_df['ratio'] = final_df['number_likes']/final_df['followers']" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 22, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>followers</th>\n", | |
| " <th>user_id</th>\n", | |
| " <th>filter</th>\n", | |
| " <th>link</th>\n", | |
| " <th>number_likes</th>\n", | |
| " <th>score</th>\n", | |
| " <th>user_name</th>\n", | |
| " <th>ratio</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>0</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xaf1...</td>\n", | |
| " <td>99</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " <td>0.047642</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xaf1...</td>\n", | |
| " <td>127</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " <td>0.061116</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xfp1...</td>\n", | |
| " <td>85</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " <td>0.040905</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>3</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xfa1...</td>\n", | |
| " <td>148</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " <td>0.071222</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>4</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xfa1...</td>\n", | |
| " <td>129</td>\n", | |
| " <td>-99</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " <td>0.062079</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " followers user_id filter \\\n", | |
| "0 2078 348548712 Normal \n", | |
| "1 2078 348548712 Normal \n", | |
| "2 2078 348548712 Normal \n", | |
| "3 2078 348548712 Normal \n", | |
| "4 2078 348548712 Normal \n", | |
| "\n", | |
| " link number_likes score \\\n", | |
| "0 https://scontent.cdninstagram.com/hphotos-xaf1... 99 -99 \n", | |
| "1 https://scontent.cdninstagram.com/hphotos-xaf1... 127 -99 \n", | |
| "2 https://scontent.cdninstagram.com/hphotos-xfp1... 85 -99 \n", | |
| "3 https://scontent.cdninstagram.com/hphotos-xfa1... 148 -99 \n", | |
| "4 https://scontent.cdninstagram.com/hphotos-xfa1... 129 -99 \n", | |
| "\n", | |
| " user_name ratio \n", | |
| "0 agarchaa 0.047642 \n", | |
| "1 agarchaa 0.061116 \n", | |
| "2 agarchaa 0.040905 \n", | |
| "3 agarchaa 0.071222 \n", | |
| "4 agarchaa 0.062079 " | |
| ] | |
| }, | |
| "execution_count": 22, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "final_df.head()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 23, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "min = final_df['ratio'].min()\n", | |
| "max = final_df['ratio'].max()\n" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 24, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "0.00271393435671\n", | |
| "0.130895091434\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "print min\n", | |
| "print max" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 25, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "scorez = np.zeros(final_df.shape[0])\n", | |
| "for index, row in final_df.iterrows():\n", | |
| " scorez[index] = float(row['ratio'] - min) / float(max - min)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 26, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "final_df['score'] = scorez" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 27, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/html": [ | |
| "<div>\n", | |
| "<table border=\"1\" class=\"dataframe\">\n", | |
| " <thead>\n", | |
| " <tr style=\"text-align: right;\">\n", | |
| " <th></th>\n", | |
| " <th>followers</th>\n", | |
| " <th>user_id</th>\n", | |
| " <th>filter</th>\n", | |
| " <th>link</th>\n", | |
| " <th>number_likes</th>\n", | |
| " <th>score</th>\n", | |
| " <th>user_name</th>\n", | |
| " <th>ratio</th>\n", | |
| " </tr>\n", | |
| " </thead>\n", | |
| " <tbody>\n", | |
| " <tr>\n", | |
| " <th>0</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xaf1...</td>\n", | |
| " <td>99</td>\n", | |
| " <td>0.350504</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " <td>0.047642</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>1</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xaf1...</td>\n", | |
| " <td>127</td>\n", | |
| " <td>0.455625</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " <td>0.061116</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>2</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xfp1...</td>\n", | |
| " <td>85</td>\n", | |
| " <td>0.297944</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " <td>0.040905</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>3</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xfa1...</td>\n", | |
| " <td>148</td>\n", | |
| " <td>0.534465</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " <td>0.071222</td>\n", | |
| " </tr>\n", | |
| " <tr>\n", | |
| " <th>4</th>\n", | |
| " <td>2078</td>\n", | |
| " <td>348548712</td>\n", | |
| " <td>Normal</td>\n", | |
| " <td>https://scontent.cdninstagram.com/hphotos-xfa1...</td>\n", | |
| " <td>129</td>\n", | |
| " <td>0.463133</td>\n", | |
| " <td>agarchaa</td>\n", | |
| " <td>0.062079</td>\n", | |
| " </tr>\n", | |
| " </tbody>\n", | |
| "</table>\n", | |
| "</div>" | |
| ], | |
| "text/plain": [ | |
| " followers user_id filter \\\n", | |
| "0 2078 348548712 Normal \n", | |
| "1 2078 348548712 Normal \n", | |
| "2 2078 348548712 Normal \n", | |
| "3 2078 348548712 Normal \n", | |
| "4 2078 348548712 Normal \n", | |
| "\n", | |
| " link number_likes score \\\n", | |
| "0 https://scontent.cdninstagram.com/hphotos-xaf1... 99 0.350504 \n", | |
| "1 https://scontent.cdninstagram.com/hphotos-xaf1... 127 0.455625 \n", | |
| "2 https://scontent.cdninstagram.com/hphotos-xfp1... 85 0.297944 \n", | |
| "3 https://scontent.cdninstagram.com/hphotos-xfa1... 148 0.534465 \n", | |
| "4 https://scontent.cdninstagram.com/hphotos-xfa1... 129 0.463133 \n", | |
| "\n", | |
| " user_name ratio \n", | |
| "0 agarchaa 0.047642 \n", | |
| "1 agarchaa 0.061116 \n", | |
| "2 agarchaa 0.040905 \n", | |
| "3 agarchaa 0.071222 \n", | |
| "4 agarchaa 0.062079 " | |
| ] | |
| }, | |
| "execution_count": 27, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "final_df.head()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 28, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "l = final_df.sort(columns='score', ascending=False)['link']" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 29, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "8 https://scontent.cdninstagram.com/hphotos-xpa1...\n", | |
| "31 https://scontent.cdninstagram.com/hphotos-xaf1...\n", | |
| "5 https://scontent.cdninstagram.com/hphotos-xaf1...\n", | |
| "7 https://scontent.cdninstagram.com/hphotos-xaf1...\n", | |
| "33 https://scontent.cdninstagram.com/hphotos-xaf1...\n", | |
| "Name: link, dtype: object" | |
| ] | |
| }, | |
| "execution_count": 29, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "l.head()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 30, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "u'https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s640x640/e35/sh0.08/11243832_990907777608569_408605106_n.jpg'" | |
| ] | |
| }, | |
| "execution_count": 30, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "l[0]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 31, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "u'https://scontent.cdninstagram.com/hphotos-xaf1/t51.2885-15/s640x640/e35/sh0.08/11351620_703709383069057_121533223_n.jpg'" | |
| ] | |
| }, | |
| "execution_count": 31, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "l[1]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 32, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "u'https://scontent.cdninstagram.com/hphotos-xfp1/t51.2885-15/s640x640/e35/sh0.08/1517250_432946686889805_774282147_n.jpg'" | |
| ] | |
| }, | |
| "execution_count": 32, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "l[2]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 33, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "u'https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s640x640/e35/sh0.08/11379890_780818035374805_1658092388_n.jpg'" | |
| ] | |
| }, | |
| "execution_count": 33, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "l[3]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 34, | |
| "metadata": { | |
| "collapsed": false | |
| }, | |
| "outputs": [ | |
| { | |
| "data": { | |
| "text/plain": [ | |
| "u'https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s640x640/e35/sh0.08/11296661_1502774936680259_299662970_n.jpg'" | |
| ] | |
| }, | |
| "execution_count": 34, | |
| "metadata": {}, | |
| "output_type": "execute_result" | |
| } | |
| ], | |
| "source": [ | |
| "l[4]" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [], | |
| "source": [] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 2", | |
| "language": "python", | |
| "name": "python2" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 2 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython2", | |
| "version": "2.7.10" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 0 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment