{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "df = pd.read_csv(\"./daten/laufen _72364c32-b839-4ad7-9ede-951a00a25b95.csv\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
sendTimeStampreceivedTimeStampaccelerationXaccelerationYaccelerationZrotationXrotationYrotationZ
017316719812541731671982625-563457-535519-33751320230000-630000037800000
117316719813561731671982744-621773-876814-5405822310000-3920000-34090000
217316719814581731671982835-432002-742004-434259-30590000-9450000-35770000
317316719815601731671982983-665571-587369-542168-8470000-16240000-21770000
417316719816621731671983045-383324-675209-33367011130000-9380000-48230000
\n", "
" ], "text/plain": [ " sendTimeStamp receivedTimeStamp accelerationX accelerationY \\\n", "0 1731671981254 1731671982625 -563457 -535519 \n", "1 1731671981356 1731671982744 -621773 -876814 \n", "2 1731671981458 1731671982835 -432002 -742004 \n", "3 1731671981560 1731671982983 -665571 -587369 \n", "4 1731671981662 1731671983045 -383324 -675209 \n", "\n", " accelerationZ rotationX rotationY rotationZ \n", "0 -337513 20230000 -6300000 37800000 \n", "1 -540582 2310000 -3920000 -34090000 \n", "2 -434259 -30590000 -9450000 -35770000 \n", "3 -542168 -8470000 -16240000 -21770000 \n", "4 -333670 11130000 -9380000 -48230000 " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head()" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [], "source": [ "test = df[\"sendTimeStamp\"].iloc[0]" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "np.int64(1731671981254)" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "test" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "import pytz\n", "from datetime import datetime" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Timestamp('1970-01-01 00:28:51.671981254')" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pd.to_datetime(test)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'1970-01-01T00:28:51.671981254'" ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# tz = pytz.timezone('Europe/Berlin')\n", "pd.to_datetime(test).isoformat()\n", "# print(datetime.fromtimestamp(test, tz).isoformat())" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1731671981254\n", "1731671981356\n", "1731671981458\n", "1731671981560\n", "1731671981662\n", "1731671981763\n", "1731671981865\n", "1731671981967\n", "1731671982069\n", "1731671982171\n", "1731671982273\n", "1731671982375\n", "1731671982476\n", "1731671982578\n", "1731671982680\n", "1731671982782\n", "1731671982884\n", "1731671982986\n", "1731671983087\n", "1731671983189\n", "1731671983291\n", "1731671983393\n", "1731671983495\n", "1731671983597\n", "1731671983698\n", "1731671983800\n", "1731671983902\n", "1731671984004\n", "1731671984106\n", "1731671984208\n", "1731671984310\n", "1731671984411\n", "1731671984513\n", "1731671984615\n", "1731671984717\n", "1731671984819\n", "1731671984921\n", "1731671985022\n", "1731671985124\n", "1731671985226\n", "1731671985328\n" ] } ], "source": [ "sendTimes = df['sendTimeStamp']\n", "\n", "for sendTime in sendTimes:\n", " print(sendTime)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df['sendTimeStamp'] = df['sendTimeStamp'].to_timestamp()" ] }, { "cell_type": "code", "execution_count": 53, "metadata": {}, "outputs": [], "source": [ "timestamps = pd.to_datetime(df['sendTimeStamp'], unit='ms')" ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "outputs": [], "source": [ "df['timestamp'] = timestamps" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
sendTimeStampreceivedTimeStampaccelerationXaccelerationYaccelerationZrotationXrotationYrotationZtimestamp
017316719812541731671982625-563457-535519-33751320230000-6300000378000002024-11-15 11:59:41.254
117316719813561731671982744-621773-876814-5405822310000-3920000-340900002024-11-15 11:59:41.356
217316719814581731671982835-432002-742004-434259-30590000-9450000-357700002024-11-15 11:59:41.458
317316719815601731671982983-665571-587369-542168-8470000-16240000-217700002024-11-15 11:59:41.560
417316719816621731671983045-383324-675209-33367011130000-9380000-482300002024-11-15 11:59:41.662
\n", "
" ], "text/plain": [ " sendTimeStamp receivedTimeStamp accelerationX accelerationY \\\n", "0 1731671981254 1731671982625 -563457 -535519 \n", "1 1731671981356 1731671982744 -621773 -876814 \n", "2 1731671981458 1731671982835 -432002 -742004 \n", "3 1731671981560 1731671982983 -665571 -587369 \n", "4 1731671981662 1731671983045 -383324 -675209 \n", "\n", " accelerationZ rotationX rotationY rotationZ timestamp \n", "0 -337513 20230000 -6300000 37800000 2024-11-15 11:59:41.254 \n", "1 -540582 2310000 -3920000 -34090000 2024-11-15 11:59:41.356 \n", "2 -434259 -30590000 -9450000 -35770000 2024-11-15 11:59:41.458 \n", "3 -542168 -8470000 -16240000 -21770000 2024-11-15 11:59:41.560 \n", "4 -333670 11130000 -9380000 -48230000 2024-11-15 11:59:41.662 " ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head()" ] }, { "cell_type": "code", "execution_count": 56, "metadata": {}, "outputs": [], "source": [ "df.to_csv(\"laufen.csv\")" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0 1970-01-01 00:28:51.671981254\n", "1 1970-01-01 00:28:51.671981356\n", "2 1970-01-01 00:28:51.671981458\n", "3 1970-01-01 00:28:51.671981560\n", "4 1970-01-01 00:28:51.671981662\n", "5 1970-01-01 00:28:51.671981763\n", "6 1970-01-01 00:28:51.671981865\n", "7 1970-01-01 00:28:51.671981967\n", "8 1970-01-01 00:28:51.671982069\n", "9 1970-01-01 00:28:51.671982171\n", "10 1970-01-01 00:28:51.671982273\n", "11 1970-01-01 00:28:51.671982375\n", "12 1970-01-01 00:28:51.671982476\n", "13 1970-01-01 00:28:51.671982578\n", "14 1970-01-01 00:28:51.671982680\n", "15 1970-01-01 00:28:51.671982782\n", "16 1970-01-01 00:28:51.671982884\n", "17 1970-01-01 00:28:51.671982986\n", "18 1970-01-01 00:28:51.671983087\n", "19 1970-01-01 00:28:51.671983189\n", "20 1970-01-01 00:28:51.671983291\n", "21 1970-01-01 00:28:51.671983393\n", "22 1970-01-01 00:28:51.671983495\n", "23 1970-01-01 00:28:51.671983597\n", "24 1970-01-01 00:28:51.671983698\n", "25 1970-01-01 00:28:51.671983800\n", "26 1970-01-01 00:28:51.671983902\n", "27 1970-01-01 00:28:51.671984004\n", "28 1970-01-01 00:28:51.671984106\n", "29 1970-01-01 00:28:51.671984208\n", "30 1970-01-01 00:28:51.671984310\n", "31 1970-01-01 00:28:51.671984411\n", "32 1970-01-01 00:28:51.671984513\n", "33 1970-01-01 00:28:51.671984615\n", "34 1970-01-01 00:28:51.671984717\n", "35 1970-01-01 00:28:51.671984819\n", "36 1970-01-01 00:28:51.671984921\n", "37 1970-01-01 00:28:51.671985022\n", "38 1970-01-01 00:28:51.671985124\n", "39 1970-01-01 00:28:51.671985226\n", "40 1970-01-01 00:28:51.671985328\n", "Name: sendTimeStamp, dtype: datetime64[ns]" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pd.to_datetime(df['sendTimeStamp'])" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "np.int64(1731671981254)" ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "test" ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2024-11-15T11:59:41.254000+00:00\n" ] } ], "source": [ "import datetime\n", "\n", "# Konvertierung in Sekunden\n", "timestamp_s = test / 1000.0\n", "\n", "# Konvertierung in ein datetime-Objekt\n", "date_time = datetime.datetime.fromtimestamp(timestamp_s, tz=datetime.timezone.utc)\n", "\n", "# Ausgabe im ISO 8601-Format\n", "iso_format = date_time.isoformat()\n", "print(iso_format)" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'2024-11-15T11:59:41.254000'" ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pd.to_datetime(test, unit='ms').isoformat()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "dataMining", "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.13.0" } }, "nbformat": 4, "nbformat_minor": 2 }