{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"This notebook takes Mike Trouts tweets from February 2021 to the beginning of May and scales the 4 matrics (retweets, like, quotes and replies) between 0 and 100 just like the target - it then plots the different metrics and Mike Trouts targtes for the same period - I now do not think that the targets are the twitter metrics based on this.","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport matplotlib.pyplot as plt","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-06-24T02:54:08.667303Z","iopub.execute_input":"2021-06-24T02:54:08.667722Z","iopub.status.idle":"2021-06-24T02:54:08.673231Z","shell.execute_reply.started":"2021-06-24T02:54:08.667689Z","shell.execute_reply":"2021-06-24T02:54:08.671975Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trout_twitter = pd.read_csv(\"../input/mike-trout-twitter-data/miketrout_tweets_2021.csv\")\ntrout_twitter.head()","metadata":{"execution":{"iopub.status.busy":"2021-06-24T03:32:41.372390Z","iopub.execute_input":"2021-06-24T03:32:41.372793Z","iopub.status.idle":"2021-06-24T03:32:41.394883Z","shell.execute_reply.started":"2021-06-24T03:32:41.372759Z","shell.execute_reply":"2021-06-24T03:32:41.394042Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"engagements = pd.read_csv(\"../input/mlb-pdef-train-dataset/nextDayPlayerEngagement_train.csv\")","metadata":{"execution":{"iopub.status.busy":"2021-06-24T03:29:47.185278Z","iopub.execute_input":"2021-06-24T03:29:47.185688Z","iopub.status.idle":"2021-06-24T03:29:50.033165Z","shell.execute_reply.started":"2021-06-24T03:29:47.185653Z","shell.execute_reply":"2021-06-24T03:29:50.032212Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# mike trout id  = 545361\nengagements = engagements[engagements['playerId'] == 545361]\nengagements['year'] = pd.DatetimeIndex(engagements['engagementMetricsDate']).year\nengagements['month'] = pd.DatetimeIndex(engagements['engagementMetricsDate']).month\n\nengagements = engagements[engagements['year'] == 2021]\nengagements = engagements[engagements['month'] > 1]","metadata":{"execution":{"iopub.status.busy":"2021-06-24T03:29:55.628786Z","iopub.execute_input":"2021-06-24T03:29:55.629203Z","iopub.status.idle":"2021-06-24T03:29:55.664847Z","shell.execute_reply.started":"2021-06-24T03:29:55.629165Z","shell.execute_reply":"2021-06-24T03:29:55.663458Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#zi = (xi – min(x)) / (max(x) – min(x)) * 100\n\ntrout_twitter=trout_twitter.head(35)\n\ntrout_twitter['like_count']=(trout_twitter['like_count']-min(trout_twitter['like_count']))/(max(trout_twitter['like_count'])-min(trout_twitter['like_count']))*100\ntrout_twitter['retweet_count']=(trout_twitter['retweet_count']-min(trout_twitter['retweet_count']))/(max(trout_twitter['retweet_count'])-min(trout_twitter['retweet_count']))*100\n\ntrout_twitter['quote_count']=(trout_twitter['quote_count']-min(trout_twitter['quote_count']))/(max(trout_twitter['quote_count'])-min(trout_twitter['quote_count']))*100\ntrout_twitter['reply_count']=(trout_twitter['reply_count']-min(trout_twitter['reply_count']))/(max(trout_twitter['reply_count'])-min(trout_twitter['reply_count']))*100","metadata":{"execution":{"iopub.status.busy":"2021-06-24T03:32:46.017265Z","iopub.execute_input":"2021-06-24T03:32:46.017642Z","iopub.status.idle":"2021-06-24T03:32:46.030290Z","shell.execute_reply.started":"2021-06-24T03:32:46.017610Z","shell.execute_reply":"2021-06-24T03:32:46.029287Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"engagements.head()","metadata":{"execution":{"iopub.status.busy":"2021-06-24T03:30:03.141878Z","iopub.execute_input":"2021-06-24T03:30:03.142283Z","iopub.status.idle":"2021-06-24T03:30:03.160011Z","shell.execute_reply.started":"2021-06-24T03:30:03.142233Z","shell.execute_reply":"2021-06-24T03:30:03.158630Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#trout_twitter.plot(x=\"created_at\", y=[\"like_count\", \"reply_count\",\"retweet_count\", \"quote_count\"])\ntrout_twitter.plot(x=\"created_at\", y=[\"like_count\"])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-06-24T03:36:02.029283Z","iopub.execute_input":"2021-06-24T03:36:02.029688Z","iopub.status.idle":"2021-06-24T03:36:02.215734Z","shell.execute_reply.started":"2021-06-24T03:36:02.029654Z","shell.execute_reply":"2021-06-24T03:36:02.214473Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#engagements.plot(x=\"engagementMetricsDate\", y=[\"target1\", \"target2\",\"target3\",\"target4\"])\nengagements.plot(x=\"engagementMetricsDate\", y=[\"target1\"])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-06-24T03:42:50.819746Z","iopub.execute_input":"2021-06-24T03:42:50.820335Z","iopub.status.idle":"2021-06-24T03:42:50.981699Z","shell.execute_reply.started":"2021-06-24T03:42:50.820298Z","shell.execute_reply":"2021-06-24T03:42:50.980445Z"},"trusted":true},"execution_count":null,"outputs":[]}]}