def single_ticker(ticker): form_data = { "request": json.dumps({ "tickers": [], "filters": [{ "column": "dataset__entity__entity_ticker__ticker__ticker", "type": "=", "value": [ticker] }], }), 'start': 1, 'limit': 1000, } items_df = thinknum_pull._get_data_multi_loop(dataset_name, form_data) #items_df["YMD"] = items_df["As Of Date"].apply(lambda x: x.encode('ascii','ignore')[:8]) #items_df["YMD"] = pd.to_datetime(items_df["YMD"]) #items_df['MONTH'] = items_df.YMD.dt.strftime("%Y-%m") items_df['As Of Date'] = pd.to_datetime(items_df['As Of Date'], format="%Y-%m-%d %H:%M:%S") #items_df['MONTH'] = pd.to_datetime(items_df['MONTH']) #items_df = items_df.sort_values(by=['YMD'], ascending = True, kind = 'mergesort') return items_df
def all_tickers(): form_data = { "request": json.dumps({ "tickers": ['nyse:mcd'], "groups": [ { "column": "dataset__entity__entity_ticker__ticker__ticker" } ], "aggregations": [ { "column": "date_added", "type": "min" }, { "column": "date_added", "type": "max" }, { "column": "date_updated", "type": "min" }, { "column": "date_updated", "type": "max" }] }), 'start': 1, 'limit': 1000, } items_df = thinknum_pull._get_data_multi_loop(dataset_name, form_data) #items_df['As Of Date'] = pd.to_datetime(items_df['As Of Date'],format = "%Y-%m-%d %H:%M:%S") return items_df
def all_ticker(): form_data = { "request": json.dumps({ "tickers": [], }), 'start': 1, 'limit': 1000, } items_df = thinknum_pull._get_data_multi_loop(dataset_name, form_data) items_df['As Of Date'] = pd.to_datetime(items_df['As Of Date'],format = "%Y-%m-%d %H:%M:%S") return items_df
def single_ticker(ticker): form_data = { "request": json.dumps({ "tickers": [], "filters": [ { "column": "dataset__entity__entity_ticker__ticker__ticker", "type": "=", "value": [ticker] }], }), 'start': 1, 'limit': 1000, } items_df = thinknum_pull._get_data_multi_loop(dataset_name, form_data) items_df['As Of Date'] = pd.to_datetime(items_df['As Of Date'],format = "%Y-%m-%d %H:%M:%S") return items_df
import seaborn as sns #import s3_pull import glob from os.path import normpath, basename import datetime dataset_name = 'social_facebook_app' form_data = { 'request': json.dumps({ 'tickers': [], }), 'start': 1, 'limit': 1000, } data = thinknum_pull._get_data_multi_loop(dataset_name, form_data) data = data.drop_duplicates() #data.at[820,'Category'] = 'Lifestyle' #cat_data = data.sort_values(['Category','Daily Active Users'], ascending=[False,False]) #col = ['Name','Daily Active Users','Weekly Active Users','Monthly Active Users','Category'] #cat_data = cat_data[col] #index = cat_data['Category']=='' #cat_data.at[index,'Category'] = 'Not Specified' ##top 5 apps in each category by daily active users #util_top = cat_data[cat_data['Category']=='Utilities'].head(9) #life_top = cat_data[cat_data['Category']=='Lifestyle'].head(10) #games_top = cat_data[cat_data['Category']=='Games'].head(6) #ent_top = cat_data[cat_data['Category']=='Entertainment'].head(17) #bus_top = cat_data[cat_data['Category']=='Business'].head(5) #sport_top = cat_data[cat_data['Category']=='Sports'].head(5) #na_top = cat_data[cat_data['Category']=='Not Specified'].head(5)