text accnt_status_hist

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text accnt_status_hist相关的知识,希望对你有一定的参考价值。

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "done\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import requests\n",
    "import json\n",
    "import copy\n",
    "import math\n",
    "import datetime\n",
    "import random\n",
    "import pprint\n",
    "\n",
    "print(\"done\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://klickly-internal-dashboard.herokuapp.com/reports/shopify_accounts_history/\n"
     ]
    }
   ],
   "source": [
    "URL = \"https://klickly-internal-dashboard.herokuapp.com/reports/shopify_accounts_history/\"\n",
    "local_URL = 'http://127.0.0.1:8000/reports/shopify_accounts_history/'\n",
    "headers = {\n",
    "    'PULSE': \"superduperpooperscooperflipflapflop\",\n",
    "    'Content-Type': \"application/json\",\n",
    "    'Cache-Control': \"no-cache\",\n",
    "    'Postman-Token': \"5396227f-c5a2-5132-3dd9-353b12755559\"\n",
    "    }\n",
    "local_headers = {\n",
    "    'PULSE': \"superduperpooperscooper\",\n",
    "    'Content-Type': \"application/json\",\n",
    "    'Cache-Control': \"no-cache\",\n",
    "    'Postman-Token': \"5396227f-c5a2-5132-3dd9-353b12755559\"\n",
    "    }\n",
    "print(URL)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2018-07-10'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "today = str( datetime.date.today() )\n",
    "today"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "./files/2-Shopify_History/shopify-klickly-app-history-2018-07-10.csv\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Event</th>\n",
       "      <th>Details</th>\n",
       "      <th>Billing on</th>\n",
       "      <th>Shop name</th>\n",
       "      <th>Shop country</th>\n",
       "      <th>Shop email</th>\n",
       "      <th>Shop domain</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2017-09-07 19:43:23 UTC</td>\n",
       "      <td>Installed</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>xaviertest45</td>\n",
       "      <td>US</td>\n",
       "      <td>xavier+45@klickly.com</td>\n",
       "      <td>xaviertest45.myshopify.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2017-09-07 21:20:33 UTC</td>\n",
       "      <td>Installed</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Mickey's Girl</td>\n",
       "      <td>US</td>\n",
       "      <td>service@mickeysgirl.com</td>\n",
       "      <td>mickeys-girl.myshopify.com</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                      Date      Event Details  Billing on       Shop name  \\\n",
       "0  2017-09-07 19:43:23 UTC  Installed     NaN         NaN    xaviertest45   \n",
       "1  2017-09-07 21:20:33 UTC  Installed     NaN         NaN  Mickey's Girl    \n",
       "\n",
       "  Shop country               Shop email                 Shop domain  \n",
       "0           US    xavier+45@klickly.com  xaviertest45.myshopify.com  \n",
       "1           US  service@mickeysgirl.com  mickeys-girl.myshopify.com  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "thisstring = './files/2-Shopify_History/shopify-klickly-app-history-'+today+'.csv'\n",
    "print(thisstring)\n",
    "df = pd.read_csv(thisstring, encoding = 'utf8')\n",
    "df.head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2863"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df.tail(120)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "120"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Event</th>\n",
       "      <th>Details</th>\n",
       "      <th>Billing on</th>\n",
       "      <th>Shop name</th>\n",
       "      <th>Shop country</th>\n",
       "      <th>Shop email</th>\n",
       "      <th>Shop domain</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2743</th>\n",
       "      <td>2018-06-25 08:50:30</td>\n",
       "      <td>Installed</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>PRD natalia store valid</td>\n",
       "      <td>US</td>\n",
       "      <td>na.roshchyna@gmail.com</td>\n",
       "      <td>prd-natalia-store-valid.myshopify.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2744</th>\n",
       "      <td>2018-06-25 08:51:37</td>\n",
       "      <td>Uninstalled</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>PRD natalia store valid</td>\n",
       "      <td>US</td>\n",
       "      <td>na.roshchyna@gmail.com</td>\n",
       "      <td>prd-natalia-store-valid.myshopify.com</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2745</th>\n",
       "      <td>2018-06-25 08:54:25</td>\n",
       "      <td>Installed</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>PRD natalia store valid</td>\n",
       "      <td>US</td>\n",
       "      <td>na.roshchyna@gmail.com</td>\n",
       "      <td>prd-natalia-store-valid.myshopify.com</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Date        Event Details  Billing on  \\\n",
       "2743  2018-06-25 08:50:30    Installed     NaN         NaN   \n",
       "2744  2018-06-25 08:51:37  Uninstalled     NaN         NaN   \n",
       "2745  2018-06-25 08:54:25    Installed     NaN         NaN   \n",
       "\n",
       "                    Shop name Shop country              Shop email  \\\n",
       "2743  PRD natalia store valid           US  na.roshchyna@gmail.com   \n",
       "2744  PRD natalia store valid           US  na.roshchyna@gmail.com   \n",
       "2745  PRD natalia store valid           US  na.roshchyna@gmail.com   \n",
       "\n",
       "                                Shop domain  \n",
       "2743  prd-natalia-store-valid.myshopify.com  \n",
       "2744  prd-natalia-store-valid.myshopify.com  \n",
       "2745  prd-natalia-store-valid.myshopify.com  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['Date'] = df['Date'].apply(lambda x: x.replace(' UTC',''))\n",
    "df.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "97"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "event_dict = {}\n",
    "#  gac \"tried to fix some stuff for historical import\"\n",
    "# .loc[0:100,:]\n",
    "start = 0\n",
    "end = 10000\n",
    "for index, row in df.loc[start:end,:].iterrows():\n",
    "    name = row['Shop domain']\n",
    "    event_dict[name] = []\n",
    "for index, row in df.loc[start:end,:].iterrows():\n",
    "    name = row['Shop domain']\n",
    "    new_event = {}\n",
    "    new_event['date'] = row['Date']#.split(' ')[0]\n",
    "    new_event['brand_name'] = row['Shop name']\n",
    "    new_event['email'] = row['Shop email']\n",
    "    new_event['event'] = row['Event']\n",
    "    new_event['country'] = row['Shop country']\n",
    "    event_dict[name].append(new_event)\n",
    "len( event_dict )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "200\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "b'{\"updated\": 59, \"created\": 16, \"count\": 97}'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "thisthing = json.dumps(event_dict)\n",
    "response = requests.request(\"POST\", url=URL, data=thisthing, headers=headers ) #    .content.decode('utf-8') \n",
    "print( response.status_code )\n",
    "response.content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "***************************************** DONE *****************************************\n"
     ]
    }
   ],
   "source": [
    "print( '***************************************** DONE *****************************************' )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda root]",
   "language": "python",
   "name": "conda-root-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

以上是关于text accnt_status_hist的主要内容,如果未能解决你的问题,请参考以下文章

<!-- text --> 和 /* text */ 注释有啥区别?

VB中 如何复制Text1.text的字体到剪贴板? 如何剪切?

VB 加减乘除

text-decoration:[ text-decoration-line ] || [ text-decoration-style ] || [ text-decoration-color ]

.text 和 .get_text() 之间的区别

javascript或css:如何隐藏标签内的文本中的任何数字,后跟点前缀“1.text”,“2.text”...“30.text”