{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pickle\n", "#import connexion\n", "with open('train.pickle', 'rb') as f:\n", " data = pickle.load(f)\n" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "datetime.datetime(2020, 12, 31, 8, 42, 19, 743852)" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dt.datetime.now()" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1.0, 3.0, 5.0, 7.0, 9.0]" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = [0,2,4,6,8,10]\n", "[a[i]+(a[i+1]-a[i])/2 for i in range(len(a)-1)]" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[datetime.datetime(2020, 12, 31, 8, 43, 21, 762229),\n", " datetime.datetime(2020, 12, 31, 12, 43, 21, 762229),\n", " datetime.datetime(2020, 12, 31, 16, 43, 21, 762229),\n", " datetime.datetime(2020, 12, 31, 20, 43, 21, 762229),\n", " datetime.datetime(2021, 1, 1, 0, 43, 21, 762229),\n", " datetime.datetime(2021, 1, 1, 4, 43, 21, 762229),\n", " datetime.datetime(2021, 1, 1, 8, 43, 21, 762229)]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import datetime as dt\n", "timedelta = dt.timedelta\n", "datetime = dt.datetime\n", "def daterange(start, stop, days = 1, hours = 0):\n", " date = start\n", " date_list = []\n", " assert(type(date)==datetime)\n", " while date <= stop:\n", " date_list.append(date)\n", " date += timedelta(days=days,hours=hours)\n", " return date_list\n", "daterange(dt.datetime.now(),dt.datetime.now()+timedelta(1),0,4)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "datetime.date(2021, 1, 1)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dt.date.today()+timedelta(1)\n" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "numpy.datetime64('2020-02-28T20:41:46.702000674')" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[0].to_datetime64()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "ename": "ModuleNotFoundError", "evalue": "No module named 'connexion'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mfunctools\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mwraps\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 12\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mconnexion\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 13\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0msentry_sdk\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mconnexion\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mProblemException\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'connexion'" ] } ], "source": [ "import random\n", "import csv\n", "import io\n", "import json\n", "\n", "import logging\n", "import os\n", "from datetime import datetime\n", "from datetime import date\n", "from functools import wraps\n", "\n", "import connexion\n", "import sentry_sdk\n", "from connexion import ProblemException\n", "from flask import render_template, request, redirect, url_for, flash, abort, Response, send_file, session\n", "from flask_assets import Environment\n", "from flask_cors import CORS\n", "from flask_mail import Mail\n", "from flask_marshmallow import Marshmallow\n", "from flask_migrate import Migrate\n", "from flask_paginate import Pagination, get_page_parameter\n", "from flask_sqlalchemy import SQLAlchemy\n", "from sqlalchemy import func\n", "from sentry_sdk.integrations.flask import FlaskIntegration\n", "from webassets import Bundle\n", "from flask_executor import Executor" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "ename": "TypeError", "evalue": "int() argument must be a string, a bytes-like object or a number, not 'datetime.datetime'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdt\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;31mTypeError\u001b[0m: int() argument must be a string, a bytes-like object or a number, not 'datetime.datetime'" ] } ], "source": [ "int(dt)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "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.8.3" } }, "nbformat": 4, "nbformat_minor": 4 }