diff --git a/timestamp.ipynb b/timestamp.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..d658d72d2549d637dc69b5b2c5954a9b0ea133fe --- /dev/null +++ b/timestamp.ipynb @@ -0,0 +1,56 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "39fc9501", + "metadata": {}, + "outputs": [], + "source": [ + "import datetime\n", + "import numpy as np\n", + "import pandas as pd\n", + "\n", + "# Plik potrzebuje ramki danych df wygenerowanej jako zapytanie SQL\n", + "\n", + "timestamp1 = df[\"TIMESTAMP\"].astype('datetime64[ns]')\n", + "\n", + "hour = timestamp1.astype('datetime64[ns]').dt.hour.astype(int)\n", + "minute = timestamp1.astype('datetime64[ns]').dt.minute.astype(int)\n", + "second = timestamp1.astype('datetime64[ns]').dt.second.astype(int)\n", + "microsecond = timestamp1.astype('datetime64[ns]').dt.microsecond.astype(int)\n", + "\n", + "millisecond = microsecond/1000+second*1000+minute*60000+hour*3600000\n", + "delta_ms = millisecond - millisecond[0]\n", + "delta_ms\n", + "\n", + "timestamp = pd.DataFrame()\n", + "timestamp = pd.concat([timestamp1, hour, minute, second, microsecond, delta_ms], axis = 1)\n", + "timestamp.columns = ['timestamp', 'hour', 'minute', 'second', 'microsecond', 'delta_ms']\n", + "\n", + "timestamp" + ] + } + ], + "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.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}