You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2882 lines
173 KiB
2882 lines
173 KiB
{
|
|
"nbformat": 4,
|
|
"nbformat_minor": 0,
|
|
"metadata": {
|
|
"colab": {
|
|
"provenance": [],
|
|
"gpuType": "V28"
|
|
},
|
|
"kernelspec": {
|
|
"name": "python3",
|
|
"display_name": "Python 3"
|
|
},
|
|
"language_info": {
|
|
"name": "python"
|
|
},
|
|
"accelerator": "TPU"
|
|
},
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"source": [
|
|
"import os\n",
|
|
"\n",
|
|
"# Define the path to your folder in Google Drive\n",
|
|
"folder_path = '/content/drive/My Drive/Data/iOS/'\n",
|
|
"\n",
|
|
"# List files in the directory (optional, to verify the files are there)\n",
|
|
"print(os.listdir(folder_path))"
|
|
],
|
|
"metadata": {
|
|
"colab": {
|
|
"base_uri": "https://localhost:8080/"
|
|
},
|
|
"id": "l0AqA2w1UaXd",
|
|
"outputId": "57108b7e-ec98-483e-f197-2d1795d333d4"
|
|
},
|
|
"execution_count": null,
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"['StepCount01.csv', 'StepCount05.csv', 'StepCount07.csv', 'StepCount09.csv', 'StepCount10.csv', 'StepCount02.csv', 'StepCount08.csv', 'StepCount06.csv', 'StepCount12.csv', 'StepCount03.csv', 'StepCount11.csv', 'StepCount04.csv', 'StepCount20.csv', 'StepCount15.csv', 'StepCount23.csv', 'StepCount17.csv', 'StepCount13.csv', 'StepCount22.csv', 'StepCount24.csv', 'StepCount19.csv', 'StepCount18.csv', 'StepCount14.csv', 'StepCount16.csv', 'StepCount21.csv', 'StepCount29.csv', 'StepCount25.csv', 'StepCount30.csv', 'StepCount26.csv', 'StepCount28.csv', 'StepCount27.csv', 'StepCount31.csv', 'StepCount33.csv', 'StepCount32.csv', 'StepCount34.csv', 'StepCount36.csv', 'StepCount39.csv', 'StepCount38.csv', 'StepCount37.csv', 'StepCount35.csv', 'StepCount42.csv', 'StepCount43.csv', 'StepCount44.csv', 'StepCount41.csv', 'StepCount45.csv', 'StepCount40.csv', 'StepCount46.csv']\n"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"source": [
|
|
"from google.colab import drive\n",
|
|
"drive.mount('/content/drive')"
|
|
],
|
|
"metadata": {
|
|
"colab": {
|
|
"base_uri": "https://localhost:8080/"
|
|
},
|
|
"id": "j-ICoG5Krvsr",
|
|
"outputId": "36255c09-8188-464a-92d9-ee581197a96b"
|
|
},
|
|
"execution_count": null,
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"source": [
|
|
"!pip install openpyxl\n",
|
|
"# Install the openpyxl package"
|
|
],
|
|
"metadata": {
|
|
"colab": {
|
|
"base_uri": "https://localhost:8080/"
|
|
},
|
|
"id": "ZprcMokxfBo8",
|
|
"outputId": "152a44df-8510-4c2c-e61b-13f1ed35edcb"
|
|
},
|
|
"execution_count": null,
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Collecting openpyxl\n",
|
|
" Downloading openpyxl-3.1.5-py2.py3-none-any.whl.metadata (2.5 kB)\n",
|
|
"Collecting et-xmlfile (from openpyxl)\n",
|
|
" Downloading et_xmlfile-1.1.0-py3-none-any.whl.metadata (1.8 kB)\n",
|
|
"Downloading openpyxl-3.1.5-py2.py3-none-any.whl (250 kB)\n",
|
|
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m250.9/250.9 kB\u001b[0m \u001b[31m1.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
|
"\u001b[?25hDownloading et_xmlfile-1.1.0-py3-none-any.whl (4.7 kB)\n",
|
|
"Installing collected packages: et-xmlfile, openpyxl\n",
|
|
"Successfully installed et-xmlfile-1.1.0 openpyxl-3.1.5\n"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"source": [
|
|
"# FINAL CODE OF 1HR WITHOUT THRESHOLD"
|
|
],
|
|
"metadata": {
|
|
"id": "oY2xhtbJMH4p"
|
|
}
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"colab": {
|
|
"base_uri": "https://localhost:8080/"
|
|
},
|
|
"collapsed": true,
|
|
"id": "i-kzVCTXtzF4",
|
|
"outputId": "4274708b-0e98-416f-9644-ad8de5e809e7"
|
|
},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-5-a4235d7882e2>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-5-a4235d7882e2>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['startDate'].dt.date\n",
|
|
"<ipython-input-5-a4235d7882e2>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['hour'] = iphone_df['startDate'].dt.hour\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"/content/drive/My Drive/Data/iOS/StepCount01.csv 0\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-5-a4235d7882e2>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-5-a4235d7882e2>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['startDate'].dt.date\n",
|
|
"<ipython-input-5-a4235d7882e2>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['hour'] = iphone_df['startDate'].dt.hour\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"/content/drive/My Drive/Data/iOS/StepCount02.csv 1\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount03.csv 2\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount04.csv 3\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-5-a4235d7882e2>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-5-a4235d7882e2>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['startDate'].dt.date\n",
|
|
"<ipython-input-5-a4235d7882e2>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['hour'] = iphone_df['startDate'].dt.hour\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"/content/drive/My Drive/Data/iOS/StepCount05.csv 4\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-5-a4235d7882e2>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-5-a4235d7882e2>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['startDate'].dt.date\n",
|
|
"<ipython-input-5-a4235d7882e2>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['hour'] = iphone_df['startDate'].dt.hour\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"/content/drive/My Drive/Data/iOS/StepCount07.csv 5\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-5-a4235d7882e2>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-5-a4235d7882e2>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['startDate'].dt.date\n",
|
|
"<ipython-input-5-a4235d7882e2>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['hour'] = iphone_df['startDate'].dt.hour\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"/content/drive/My Drive/Data/iOS/StepCount08.csv 6\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount09.csv 7\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount11.csv 8\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount14.csv 9\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount16.csv 10\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount19.csv 11\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount21.csv 12\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount22.csv 13\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-5-a4235d7882e2>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-5-a4235d7882e2>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['startDate'].dt.date\n",
|
|
"<ipython-input-5-a4235d7882e2>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['hour'] = iphone_df['startDate'].dt.hour\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"/content/drive/My Drive/Data/iOS/StepCount23.csv 14\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-5-a4235d7882e2>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-5-a4235d7882e2>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['startDate'].dt.date\n",
|
|
"<ipython-input-5-a4235d7882e2>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['hour'] = iphone_df['startDate'].dt.hour\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"/content/drive/My Drive/Data/iOS/StepCount25.csv 15\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount26.csv 16\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-5-a4235d7882e2>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-5-a4235d7882e2>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['startDate'].dt.date\n",
|
|
"<ipython-input-5-a4235d7882e2>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['hour'] = iphone_df['startDate'].dt.hour\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"/content/drive/My Drive/Data/iOS/StepCount28.csv 17\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount29.csv 18\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount30.csv 19\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-5-a4235d7882e2>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-5-a4235d7882e2>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['startDate'].dt.date\n",
|
|
"<ipython-input-5-a4235d7882e2>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['hour'] = iphone_df['startDate'].dt.hour\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"/content/drive/My Drive/Data/iOS/StepCount33.csv 20\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount34.csv 21\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount35.csv 22\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount36.csv 23\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-5-a4235d7882e2>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-5-a4235d7882e2>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['startDate'].dt.date\n",
|
|
"<ipython-input-5-a4235d7882e2>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['hour'] = iphone_df['startDate'].dt.hour\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"/content/drive/My Drive/Data/iOS/StepCount37.csv 24\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-5-a4235d7882e2>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-5-a4235d7882e2>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['startDate'].dt.date\n",
|
|
"<ipython-input-5-a4235d7882e2>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['hour'] = iphone_df['startDate'].dt.hour\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"/content/drive/My Drive/Data/iOS/StepCount38.csv 25\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount39.csv 26\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-5-a4235d7882e2>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-5-a4235d7882e2>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['startDate'].dt.date\n",
|
|
"<ipython-input-5-a4235d7882e2>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['hour'] = iphone_df['startDate'].dt.hour\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"/content/drive/My Drive/Data/iOS/StepCount40.csv 27\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-5-a4235d7882e2>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-5-a4235d7882e2>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['startDate'].dt.date\n",
|
|
"<ipython-input-5-a4235d7882e2>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['hour'] = iphone_df['startDate'].dt.hour\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"/content/drive/My Drive/Data/iOS/StepCount41.csv 28\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount43.csv 29\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount44.csv 30\n",
|
|
"/content/drive/My Drive/Data/iOS/StepCount45.csv 31\n",
|
|
" date Hour_0 Hour_1 Hour_2 Hour_3 Hour_4 Hour_5 Hour_6 \\\n",
|
|
"0 2017-07-20 False False False False False False False \n",
|
|
"1 2017-07-21 False False False False False False False \n",
|
|
"2 2017-07-22 True True False False False False False \n",
|
|
"3 2017-07-23 False False False False False False False \n",
|
|
"4 2017-07-24 True True False False False False False \n",
|
|
"... ... ... ... ... ... ... ... ... \n",
|
|
"36480 2020-06-09 True False False False False False False \n",
|
|
"36481 2020-06-10 False False True False False False False \n",
|
|
"36482 2020-06-11 True False False False False False True \n",
|
|
"36483 2020-06-12 True False False False False False False \n",
|
|
"36484 2020-06-13 True False False False False False False \n",
|
|
"\n",
|
|
" Hour_7 Hour_8 ... Month Year DayOfWeek_Friday DayOfWeek_Monday \\\n",
|
|
"0 False False ... 7 2017 False False \n",
|
|
"1 True True ... 7 2017 True False \n",
|
|
"2 True True ... 7 2017 False False \n",
|
|
"3 False True ... 7 2017 False False \n",
|
|
"4 False True ... 7 2017 False True \n",
|
|
"... ... ... ... ... ... ... ... \n",
|
|
"36480 False False ... 6 2020 False False \n",
|
|
"36481 False False ... 6 2020 False False \n",
|
|
"36482 True True ... 6 2020 False False \n",
|
|
"36483 False False ... 6 2020 True False \n",
|
|
"36484 False False ... 6 2020 False False \n",
|
|
"\n",
|
|
" DayOfWeek_Saturday DayOfWeek_Sunday DayOfWeek_Thursday \\\n",
|
|
"0 False False True \n",
|
|
"1 False False False \n",
|
|
"2 True False False \n",
|
|
"3 False True False \n",
|
|
"4 False False False \n",
|
|
"... ... ... ... \n",
|
|
"36480 False False False \n",
|
|
"36481 False False False \n",
|
|
"36482 False False True \n",
|
|
"36483 False False False \n",
|
|
"36484 True False False \n",
|
|
"\n",
|
|
" DayOfWeek_Tuesday DayOfWeek_Wednesday user \n",
|
|
"0 False False 0 \n",
|
|
"1 False False 0 \n",
|
|
"2 False False 0 \n",
|
|
"3 False False 0 \n",
|
|
"4 False False 0 \n",
|
|
"... ... ... ... \n",
|
|
"36480 True False 31 \n",
|
|
"36481 False True 31 \n",
|
|
"36482 False False 31 \n",
|
|
"36483 False False 31 \n",
|
|
"36484 False False 31 \n",
|
|
"\n",
|
|
"[36485 rows x 35 columns]\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import pandas as pd\n",
|
|
"\n",
|
|
"def process_file(file_path, user_label):\n",
|
|
"\n",
|
|
" # Load the dataset\n",
|
|
" df = pd.read_csv(file_path, delimiter=';')\n",
|
|
"\n",
|
|
" # Step 1: Filter for iPhone devices\n",
|
|
" iphone_df = df[df['device'].str.contains('iPhone', na=False)] # Treat NaN as False\n",
|
|
"\n",
|
|
" # Step 2: Select the desired columns\n",
|
|
" result = iphone_df[['startDate', 'endDate', 'value']]\n",
|
|
"\n",
|
|
" # Step 3: Convert startDate to datetime\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"\n",
|
|
" # Step 4: Extract date and hour\n",
|
|
" iphone_df['date'] = iphone_df['startDate'].dt.date\n",
|
|
" iphone_df['hour'] = iphone_df['startDate'].dt.hour\n",
|
|
"\n",
|
|
" # Step 5: Group by date and hour, then sum the values\n",
|
|
" hourly_sum = iphone_df.groupby(['date', 'hour'])['value'].sum().reset_index()\n",
|
|
"\n",
|
|
" # Step 6: Pivot the data to get one row per day with 24 columns for each hour\n",
|
|
" pivot_table = hourly_sum.pivot(index='date', columns='hour', values='value').fillna(0)\n",
|
|
"\n",
|
|
" # Step 7: Rename columns to reflect hours\n",
|
|
" pivot_table.columns = [f'Hour_{i}' for i in pivot_table.columns]\n",
|
|
"\n",
|
|
" # Step 8: Reset index to have 'date' as a column instead of index\n",
|
|
" pivot_table.reset_index(inplace=True)\n",
|
|
"\n",
|
|
" # Step 9: Add day of the week, month, and year columns\n",
|
|
" pivot_table['DayOfWeek'] = pd.to_datetime(pivot_table['date']).dt.day_name()\n",
|
|
" pivot_table['Month'] = pd.to_datetime(pivot_table['date']).dt.month\n",
|
|
" pivot_table['Year'] = pd.to_datetime(pivot_table['date']).dt.year\n",
|
|
"\n",
|
|
" # Step 10: One-hot encode the 'DayOfWeek' column\n",
|
|
" pivot_table = pd.concat([pivot_table, pd.get_dummies(pivot_table['DayOfWeek'], prefix='DayOfWeek')], axis=1)\n",
|
|
"\n",
|
|
" # Step 11: Convert hourly values to binary (True if > 0, else False)\n",
|
|
" for col in pivot_table.columns[1:25]: # Skip the 'date' column and focus on hours\n",
|
|
" pivot_table[col] = pivot_table[col].apply(lambda x: True if x > 0 else False)\n",
|
|
"\n",
|
|
" # Step 12: Add 'user' column with the specified user label\n",
|
|
" pivot_table['user'] = user_label\n",
|
|
" # Print which file is currently being processed\n",
|
|
" print(file_path,user_label)\n",
|
|
" # Step 13: Drop the 'DayOfWeek' column\n",
|
|
" pivot_table.drop(columns=['DayOfWeek'], inplace=True)\n",
|
|
"\n",
|
|
" return pivot_table\n",
|
|
"\n",
|
|
"# List of files to skip\n",
|
|
"files_to_skip = {'StepCount06.csv','StepCount10.csv','StepCount12.csv', 'StepCount13.csv', 'StepCount15.csv', 'StepCount17.csv',\n",
|
|
" 'StepCount18.csv', 'StepCount20.csv', 'StepCount24.csv','StepCount27.csv', 'StepCount31.csv','StepCount32.csv',\n",
|
|
" 'StepCount42.csv', 'StepCount46.csv'}\n",
|
|
"\n",
|
|
"# Generate file paths, skipping specified files\n",
|
|
"file_paths = [f'/content/drive/My Drive/Data/iOS/StepCount{i:02d}.csv' for i in range(1, 47)\n",
|
|
" if f'StepCount{i:02d}.csv' not in files_to_skip]\n",
|
|
"\n",
|
|
"# Generate user labels based on file index\n",
|
|
"user_labels = list(range(len(file_paths)))\n",
|
|
"\n",
|
|
"\n",
|
|
"# Process each file with its corresponding user label and concatenate the results\n",
|
|
"processed_dfs = [process_file(file_path, user_label) for file_path, user_label in zip(file_paths, user_labels)]\n",
|
|
"combined_df = pd.concat(processed_dfs, ignore_index=True)\n",
|
|
"\n",
|
|
"# Save the combined DataFrame to a new Excel file\n",
|
|
"updated_file_path = '/content/combined_aggregated_data.xlsx'\n",
|
|
"combined_df.to_excel(updated_file_path, index=False)\n",
|
|
"\n",
|
|
"# Print the final DataFrame\n",
|
|
"print(combined_df)\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"source": [
|
|
"\n",
|
|
"# 15MIN WITHOUT THRESHOLD"
|
|
],
|
|
"metadata": {
|
|
"id": "yGsfgd6gL2zD"
|
|
}
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"source": [
|
|
"import pandas as pd\n",
|
|
"import numpy as np\n",
|
|
"\n",
|
|
"def process_file(file_path, user_label):\n",
|
|
" # Load the dataset\n",
|
|
" df = pd.read_csv(file_path, delimiter=';')\n",
|
|
"\n",
|
|
" # Filter for iPhone devices\n",
|
|
" iphone_df = df[df['device'].str.contains('iPhone', na=False)]\n",
|
|
"\n",
|
|
" # Convert startDate to datetime\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"\n",
|
|
" # Round down the startDate to the nearest 15-minute interval\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"\n",
|
|
" # Extract date, time, year, and month for 15-minute intervals\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
" iphone_df['Year'] = iphone_df['15min_interval'].dt.year\n",
|
|
" iphone_df['Month'] = iphone_df['15min_interval'].dt.month\n",
|
|
"\n",
|
|
" # Group by date, time, year, and month, then sum the values\n",
|
|
"\n",
|
|
"\n",
|
|
" interval_sum = iphone_df.groupby(['date', 'time', 'Year', 'Month'])['value'].sum().reset_index()\n",
|
|
"\n",
|
|
" # Create a full range of 15-minute intervals (00:00:00 to 23:45:00)\n",
|
|
" full_time_range = pd.date_range('00:00', '23:45', freq='15T').time\n",
|
|
"\n",
|
|
" # Pivot the data to get one row per day with columns for each 15-minute interval\n",
|
|
" pivot_table = interval_sum.pivot(index=['date', 'Year', 'Month'], columns='time', values='value').fillna(0)\n",
|
|
"\n",
|
|
" # Reindex to include all possible 15-minute intervals\n",
|
|
" pivot_table = pivot_table.reindex(columns=full_time_range, fill_value=0)\n",
|
|
"\n",
|
|
" # Rename columns to reflect 15-minute intervals\n",
|
|
" pivot_table.columns = [f'{str(col)}' for col in pivot_table.columns]\n",
|
|
"\n",
|
|
" # Convert interval values to boolean (True if > 0, else False)\n",
|
|
" pivot_table = pivot_table.apply(lambda col: col != 0, axis=0)\n",
|
|
"\n",
|
|
" # Reset index to have 'date', 'Year', and 'Month' as columns instead of index\n",
|
|
" pivot_table.reset_index(inplace=True)\n",
|
|
"\n",
|
|
" # Add day of the week\n",
|
|
" pivot_table['DayOfWeek'] = pd.to_datetime(pivot_table['date']).dt.day_name()\n",
|
|
"\n",
|
|
" # One-hot encode the 'DayOfWeek' column\n",
|
|
" pivot_table = pd.concat([pivot_table, pd.get_dummies(pivot_table['DayOfWeek'], prefix='DayOfWeek')], axis=1)\n",
|
|
"\n",
|
|
" # Add a user column with the specified user label\n",
|
|
" pivot_table['user'] = user_label\n",
|
|
"\n",
|
|
" # Print which file is currently being processed\n",
|
|
" print(f\"Processing file: {file_path}, User label: {user_label}\")\n",
|
|
"\n",
|
|
" return pivot_table\n",
|
|
"\n",
|
|
"# List of files to skip\n",
|
|
"files_to_skip = {'StepCount06.csv','StepCount10.csv','StepCount12.csv', 'StepCount13.csv', 'StepCount15.csv', 'StepCount17.csv',\n",
|
|
" 'StepCount18.csv', 'StepCount20.csv', 'StepCount24.csv', 'StepCount27.csv','StepCount31.csv','StepCount32.csv',\n",
|
|
" 'StepCount42.csv', 'StepCount46.csv'}\n",
|
|
"\n",
|
|
"# Generate file paths, skipping specified files\n",
|
|
"file_paths = [f'/content/drive/My Drive/Data/iOS/StepCount{i:02d}.csv' for i in range(1, 47)\n",
|
|
" if f'StepCount{i:02d}.csv' not in files_to_skip]\n",
|
|
"\n",
|
|
"# Generate user labels based on file index\n",
|
|
"user_labels = list(range(len(file_paths)))\n",
|
|
"\n",
|
|
"# Process each file with its corresponding user label and concatenate the results\n",
|
|
"processed_dfs = [process_file(file_path, user_label) for file_path, user_label in zip(file_paths, user_labels)]\n",
|
|
"combined_df = pd.concat(processed_dfs, ignore_index=True)\n",
|
|
"\n",
|
|
"# Save the combined DataFrame to a new Excel file\n",
|
|
"updated_file_path = '/content/combined_aggregated_data_15min_without_threshold.xlsx'\n",
|
|
"combined_df.to_excel(updated_file_path, index=False)\n",
|
|
"\n",
|
|
"# Print the final DataFrame\n",
|
|
"print(combined_df)\n"
|
|
],
|
|
"metadata": {
|
|
"colab": {
|
|
"base_uri": "https://localhost:8080/"
|
|
},
|
|
"id": "0wtxqkYAhLMe",
|
|
"outputId": "43e7e468-8cc3-4864-edaa-1b11df3349f8",
|
|
"collapsed": true
|
|
},
|
|
"execution_count": null,
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-4-36a1c351e706>:12: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-4-36a1c351e706>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-4-36a1c351e706>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-4-36a1c351e706>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
"<ipython-input-4-36a1c351e706>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Year'] = iphone_df['15min_interval'].dt.year\n",
|
|
"<ipython-input-4-36a1c351e706>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Month'] = iphone_df['15min_interval'].dt.month\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount01.csv, User label: 0\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-4-36a1c351e706>:12: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-4-36a1c351e706>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-4-36a1c351e706>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-4-36a1c351e706>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
"<ipython-input-4-36a1c351e706>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Year'] = iphone_df['15min_interval'].dt.year\n",
|
|
"<ipython-input-4-36a1c351e706>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Month'] = iphone_df['15min_interval'].dt.month\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount02.csv, User label: 1\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount03.csv, User label: 2\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount04.csv, User label: 3\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-4-36a1c351e706>:12: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-4-36a1c351e706>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-4-36a1c351e706>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-4-36a1c351e706>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
"<ipython-input-4-36a1c351e706>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Year'] = iphone_df['15min_interval'].dt.year\n",
|
|
"<ipython-input-4-36a1c351e706>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Month'] = iphone_df['15min_interval'].dt.month\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount05.csv, User label: 4\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-4-36a1c351e706>:12: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-4-36a1c351e706>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-4-36a1c351e706>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-4-36a1c351e706>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
"<ipython-input-4-36a1c351e706>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Year'] = iphone_df['15min_interval'].dt.year\n",
|
|
"<ipython-input-4-36a1c351e706>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Month'] = iphone_df['15min_interval'].dt.month\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount07.csv, User label: 5\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-4-36a1c351e706>:12: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-4-36a1c351e706>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-4-36a1c351e706>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-4-36a1c351e706>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
"<ipython-input-4-36a1c351e706>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Year'] = iphone_df['15min_interval'].dt.year\n",
|
|
"<ipython-input-4-36a1c351e706>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Month'] = iphone_df['15min_interval'].dt.month\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount08.csv, User label: 6\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount09.csv, User label: 7\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount11.csv, User label: 8\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount14.csv, User label: 9\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount16.csv, User label: 10\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount19.csv, User label: 11\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount21.csv, User label: 12\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount22.csv, User label: 13\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-4-36a1c351e706>:12: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-4-36a1c351e706>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-4-36a1c351e706>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-4-36a1c351e706>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
"<ipython-input-4-36a1c351e706>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Year'] = iphone_df['15min_interval'].dt.year\n",
|
|
"<ipython-input-4-36a1c351e706>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Month'] = iphone_df['15min_interval'].dt.month\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount23.csv, User label: 14\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-4-36a1c351e706>:12: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-4-36a1c351e706>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-4-36a1c351e706>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-4-36a1c351e706>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
"<ipython-input-4-36a1c351e706>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Year'] = iphone_df['15min_interval'].dt.year\n",
|
|
"<ipython-input-4-36a1c351e706>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Month'] = iphone_df['15min_interval'].dt.month\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount25.csv, User label: 15\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount26.csv, User label: 16\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-4-36a1c351e706>:12: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-4-36a1c351e706>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-4-36a1c351e706>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-4-36a1c351e706>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
"<ipython-input-4-36a1c351e706>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Year'] = iphone_df['15min_interval'].dt.year\n",
|
|
"<ipython-input-4-36a1c351e706>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Month'] = iphone_df['15min_interval'].dt.month\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount28.csv, User label: 17\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount29.csv, User label: 18\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount30.csv, User label: 19\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-4-36a1c351e706>:12: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-4-36a1c351e706>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-4-36a1c351e706>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-4-36a1c351e706>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
"<ipython-input-4-36a1c351e706>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Year'] = iphone_df['15min_interval'].dt.year\n",
|
|
"<ipython-input-4-36a1c351e706>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Month'] = iphone_df['15min_interval'].dt.month\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount33.csv, User label: 20\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount34.csv, User label: 21\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount35.csv, User label: 22\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount36.csv, User label: 23\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-4-36a1c351e706>:12: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-4-36a1c351e706>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-4-36a1c351e706>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-4-36a1c351e706>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
"<ipython-input-4-36a1c351e706>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Year'] = iphone_df['15min_interval'].dt.year\n",
|
|
"<ipython-input-4-36a1c351e706>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Month'] = iphone_df['15min_interval'].dt.month\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount37.csv, User label: 24\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-4-36a1c351e706>:12: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-4-36a1c351e706>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-4-36a1c351e706>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-4-36a1c351e706>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
"<ipython-input-4-36a1c351e706>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Year'] = iphone_df['15min_interval'].dt.year\n",
|
|
"<ipython-input-4-36a1c351e706>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Month'] = iphone_df['15min_interval'].dt.month\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount38.csv, User label: 25\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount39.csv, User label: 26\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-4-36a1c351e706>:12: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-4-36a1c351e706>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-4-36a1c351e706>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-4-36a1c351e706>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
"<ipython-input-4-36a1c351e706>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Year'] = iphone_df['15min_interval'].dt.year\n",
|
|
"<ipython-input-4-36a1c351e706>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Month'] = iphone_df['15min_interval'].dt.month\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount40.csv, User label: 27\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-4-36a1c351e706>:12: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-4-36a1c351e706>:15: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-4-36a1c351e706>:18: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-4-36a1c351e706>:19: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
"<ipython-input-4-36a1c351e706>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Year'] = iphone_df['15min_interval'].dt.year\n",
|
|
"<ipython-input-4-36a1c351e706>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['Month'] = iphone_df['15min_interval'].dt.month\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount41.csv, User label: 28\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount43.csv, User label: 29\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount44.csv, User label: 30\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount45.csv, User label: 31\n",
|
|
" date Year Month 00:00:00 00:15:00 00:30:00 00:45:00 \\\n",
|
|
"0 2017-07-20 2017 7 False False False False \n",
|
|
"1 2017-07-21 2017 7 False False False False \n",
|
|
"2 2017-07-22 2017 7 False False False True \n",
|
|
"3 2017-07-23 2017 7 False False False False \n",
|
|
"4 2017-07-24 2017 7 False True False False \n",
|
|
"... ... ... ... ... ... ... ... \n",
|
|
"36480 2020-06-09 2020 6 False False True False \n",
|
|
"36481 2020-06-10 2020 6 False False False False \n",
|
|
"36482 2020-06-11 2020 6 False True False False \n",
|
|
"36483 2020-06-12 2020 6 False False True False \n",
|
|
"36484 2020-06-13 2020 6 False False True False \n",
|
|
"\n",
|
|
" 01:00:00 01:15:00 01:30:00 ... 23:45:00 DayOfWeek \\\n",
|
|
"0 False False False ... False Thursday \n",
|
|
"1 False False False ... False Friday \n",
|
|
"2 True False False ... False Saturday \n",
|
|
"3 False False False ... False Sunday \n",
|
|
"4 False False True ... False Monday \n",
|
|
"... ... ... ... ... ... ... \n",
|
|
"36480 False False False ... False Tuesday \n",
|
|
"36481 False False False ... False Wednesday \n",
|
|
"36482 False False False ... False Thursday \n",
|
|
"36483 False False False ... False Friday \n",
|
|
"36484 False False False ... False Saturday \n",
|
|
"\n",
|
|
" DayOfWeek_Friday DayOfWeek_Monday DayOfWeek_Saturday \\\n",
|
|
"0 False False False \n",
|
|
"1 True False False \n",
|
|
"2 False False True \n",
|
|
"3 False False False \n",
|
|
"4 False True False \n",
|
|
"... ... ... ... \n",
|
|
"36480 False False False \n",
|
|
"36481 False False False \n",
|
|
"36482 False False False \n",
|
|
"36483 True False False \n",
|
|
"36484 False False True \n",
|
|
"\n",
|
|
" DayOfWeek_Sunday DayOfWeek_Thursday DayOfWeek_Tuesday \\\n",
|
|
"0 False True False \n",
|
|
"1 False False False \n",
|
|
"2 False False False \n",
|
|
"3 True False False \n",
|
|
"4 False False False \n",
|
|
"... ... ... ... \n",
|
|
"36480 False False True \n",
|
|
"36481 False False False \n",
|
|
"36482 False True False \n",
|
|
"36483 False False False \n",
|
|
"36484 False False False \n",
|
|
"\n",
|
|
" DayOfWeek_Wednesday user \n",
|
|
"0 False 0 \n",
|
|
"1 False 0 \n",
|
|
"2 False 0 \n",
|
|
"3 False 0 \n",
|
|
"4 False 0 \n",
|
|
"... ... ... \n",
|
|
"36480 False 31 \n",
|
|
"36481 True 31 \n",
|
|
"36482 False 31 \n",
|
|
"36483 False 31 \n",
|
|
"36484 False 31 \n",
|
|
"\n",
|
|
"[36485 rows x 108 columns]\n"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"source": [
|
|
"user_counts = combined_df['user'].value_counts()\n",
|
|
"\n",
|
|
"# Display the count of each user\n",
|
|
"print(user_counts.sort_index())"
|
|
],
|
|
"metadata": {
|
|
"colab": {
|
|
"base_uri": "https://localhost:8080/"
|
|
},
|
|
"id": "xmiiOmq_G0rJ",
|
|
"outputId": "e783652e-168b-487d-a272-74ca465a8b69"
|
|
},
|
|
"execution_count": null,
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"user\n",
|
|
"0 1025\n",
|
|
"1 1713\n",
|
|
"2 796\n",
|
|
"3 889\n",
|
|
"4 1656\n",
|
|
"5 498\n",
|
|
"6 880\n",
|
|
"7 1094\n",
|
|
"8 954\n",
|
|
"9 1657\n",
|
|
"10 1584\n",
|
|
"11 1561\n",
|
|
"12 1513\n",
|
|
"13 802\n",
|
|
"14 1388\n",
|
|
"15 1058\n",
|
|
"16 782\n",
|
|
"17 1155\n",
|
|
"18 810\n",
|
|
"19 1112\n",
|
|
"20 1555\n",
|
|
"21 1362\n",
|
|
"22 656\n",
|
|
"23 1289\n",
|
|
"24 829\n",
|
|
"25 1623\n",
|
|
"26 568\n",
|
|
"27 1621\n",
|
|
"28 1154\n",
|
|
"29 664\n",
|
|
"30 976\n",
|
|
"31 1261\n",
|
|
"Name: count, dtype: int64\n"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"source": [
|
|
"**FINAL CODE OF 15MIN WITH THRESHOLD**"
|
|
],
|
|
"metadata": {
|
|
"id": "iJ4j1YoZ7KbJ"
|
|
}
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"source": [
|
|
"import pandas as pd\n",
|
|
"\n",
|
|
"def process_file(file_path, user_label):\n",
|
|
" # Load the dataset\n",
|
|
" df = pd.read_csv(file_path, delimiter=';')\n",
|
|
"\n",
|
|
" # Step 1: Filter for iPhone devices\n",
|
|
" iphone_df = df[df['device'].str.contains('iPhone', na=False)] # Treat NaN as False\n",
|
|
"\n",
|
|
" # Step 2: Select the desired columns\n",
|
|
" result = iphone_df[['startDate', 'endDate', 'value']]\n",
|
|
"\n",
|
|
" # Step 3: Convert startDate to datetime\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"\n",
|
|
" # Step 4: Round down the startDate to the nearest 15-minute interval\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"\n",
|
|
" # Step 5: Extract date and time\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
"\n",
|
|
" # Step 6: Group by date and time, then sum the values for 15-minute intervals\n",
|
|
" iphone_df_filtered = iphone_df[iphone_df['value'] > 25].dropna(subset=['value'])\n",
|
|
" interval_sum = iphone_df.groupby(['date', 'time'])['value'].sum().reset_index()\n",
|
|
"\n",
|
|
" # Step 7: Pivot the data to get one row per day with columns for each 15-minute interval\n",
|
|
" pivot_table = interval_sum.pivot(index='date', columns='time', values='value').fillna(0)\n",
|
|
"\n",
|
|
" # Step 8: Create a full range of 15-minute intervals (00:00:00 to 23:45:00)\n",
|
|
" full_time_range = pd.date_range('00:00', '23:45', freq='15T').time\n",
|
|
"\n",
|
|
" # Step 9: Reindex to include all possible 15-minute intervals and fill missing values with 0\n",
|
|
" pivot_table = pivot_table.reindex(columns=full_time_range, fill_value=0)\n",
|
|
"\n",
|
|
" # Step 10: Rename columns to reflect 15-minute intervals\n",
|
|
" pivot_table.columns = [f'{str(col)}' for col in pivot_table.columns]\n",
|
|
"\n",
|
|
" # Step 11: Reset index to have 'date' as a column instead of an index\n",
|
|
" pivot_table.reset_index(inplace=True)\n",
|
|
"\n",
|
|
" # Step 12: Add day of the week, month, and year columns\n",
|
|
" pivot_table['DayOfWeek'] = pd.to_datetime(pivot_table['date']).dt.day_name()\n",
|
|
" pivot_table['Month'] = pd.to_datetime(pivot_table['date']).dt.month\n",
|
|
" pivot_table['Year'] = pd.to_datetime(pivot_table['date']).dt.year\n",
|
|
"\n",
|
|
" # Step 13: One-hot encode the 'DayOfWeek' column\n",
|
|
" pivot_table = pd.concat([pivot_table, pd.get_dummies(pivot_table['DayOfWeek'], prefix='DayOfWeek')], axis=1)\n",
|
|
"\n",
|
|
" # Step 14: Convert 15-minute interval values to binary (True if > 0, else False)\n",
|
|
" for col in pivot_table.columns[1:97]: # Skip the 'date' column and focus on 15-minute intervals\n",
|
|
" pivot_table[col] = pivot_table[col].apply(lambda x: True if x > 0 else False)\n",
|
|
"\n",
|
|
" # Step 15: Add 'user' column with the specified user label\n",
|
|
" pivot_table['user'] = user_label\n",
|
|
"\n",
|
|
" # Print which file is currently being processed\n",
|
|
" print(f\"Processing file: {file_path}, User label: {user_label}\")\n",
|
|
"\n",
|
|
" # Step 16: Drop the 'DayOfWeek' column as it has been one-hot encoded\n",
|
|
" pivot_table.drop(columns=['DayOfWeek'], inplace=True)\n",
|
|
"\n",
|
|
" return pivot_table\n",
|
|
"\n",
|
|
"# List of files to skip\n",
|
|
"files_to_skip = {'StepCount06.csv','StepCount10.csv','StepCount12.csv', 'StepCount13.csv', 'StepCount15.csv', 'StepCount17.csv',\n",
|
|
" 'StepCount18.csv', 'StepCount20.csv', 'StepCount24.csv', 'StepCount27.csv','StepCount31.csv','StepCount32.csv',\n",
|
|
" 'StepCount42.csv', 'StepCount46.csv'}\n",
|
|
"\n",
|
|
"# Generate file paths, skipping specified files\n",
|
|
"file_paths = [f'/content/drive/My Drive/Data/iOS/StepCount{i:02d}.csv' for i in range(1, 47)\n",
|
|
" if f'StepCount{i:02d}.csv' not in files_to_skip]\n",
|
|
"\n",
|
|
"# Generate user labels based on file index\n",
|
|
"user_labels = list(range(len(file_paths)))\n",
|
|
"\n",
|
|
"# Process each file with its corresponding user label and concatenate the results\n",
|
|
"processed_dfs = [process_file(file_path, user_label) for file_path, user_label in zip(file_paths, user_labels)]\n",
|
|
"combined_df = pd.concat(processed_dfs, ignore_index=True)\n",
|
|
"\n",
|
|
"# Save the combined DataFrame to a new Excel file\n",
|
|
"updated_file_path = '/content/combined_aggregated_data_15min_with_threshold.xlsx'\n",
|
|
"combined_df.to_excel(updated_file_path, index=False)\n",
|
|
"\n",
|
|
"# Print the final DataFrame\n",
|
|
"print(combined_df)\n"
|
|
],
|
|
"metadata": {
|
|
"id": "w9RRwHj2wcbI",
|
|
"colab": {
|
|
"base_uri": "https://localhost:8080/"
|
|
},
|
|
"outputId": "da82f9b0-54f0-45eb-c823-109d1e244002",
|
|
"collapsed": true
|
|
},
|
|
"execution_count": null,
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-7-a477c39a373a>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-7-a477c39a373a>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-7-a477c39a373a>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-7-a477c39a373a>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount01.csv, User label: 0\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-7-a477c39a373a>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-7-a477c39a373a>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-7-a477c39a373a>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-7-a477c39a373a>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount02.csv, User label: 1\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount03.csv, User label: 2\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount04.csv, User label: 3\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-7-a477c39a373a>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-7-a477c39a373a>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-7-a477c39a373a>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-7-a477c39a373a>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount05.csv, User label: 4\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount07.csv, User label: 5\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-7-a477c39a373a>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-7-a477c39a373a>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-7-a477c39a373a>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-7-a477c39a373a>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n",
|
|
"<ipython-input-7-a477c39a373a>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-7-a477c39a373a>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-7-a477c39a373a>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-7-a477c39a373a>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount08.csv, User label: 6\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount09.csv, User label: 7\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount11.csv, User label: 8\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount14.csv, User label: 9\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount16.csv, User label: 10\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount19.csv, User label: 11\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount21.csv, User label: 12\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount22.csv, User label: 13\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-7-a477c39a373a>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-7-a477c39a373a>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-7-a477c39a373a>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-7-a477c39a373a>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount23.csv, User label: 14\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-7-a477c39a373a>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-7-a477c39a373a>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-7-a477c39a373a>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-7-a477c39a373a>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount25.csv, User label: 15\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount26.csv, User label: 16\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-7-a477c39a373a>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-7-a477c39a373a>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-7-a477c39a373a>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-7-a477c39a373a>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount28.csv, User label: 17\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount29.csv, User label: 18\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount30.csv, User label: 19\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-7-a477c39a373a>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-7-a477c39a373a>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-7-a477c39a373a>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-7-a477c39a373a>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount33.csv, User label: 20\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount34.csv, User label: 21\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount35.csv, User label: 22\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount36.csv, User label: 23\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-7-a477c39a373a>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-7-a477c39a373a>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-7-a477c39a373a>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-7-a477c39a373a>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount37.csv, User label: 24\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-7-a477c39a373a>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-7-a477c39a373a>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-7-a477c39a373a>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-7-a477c39a373a>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount38.csv, User label: 25\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount39.csv, User label: 26\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-7-a477c39a373a>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-7-a477c39a373a>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-7-a477c39a373a>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-7-a477c39a373a>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount40.csv, User label: 27\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-7-a477c39a373a>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-7-a477c39a373a>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['15min_interval'] = iphone_df['startDate'].dt.floor('15T')\n",
|
|
"<ipython-input-7-a477c39a373a>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['15min_interval'].dt.date\n",
|
|
"<ipython-input-7-a477c39a373a>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['15min_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount41.csv, User label: 28\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount43.csv, User label: 29\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount44.csv, User label: 30\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount45.csv, User label: 31\n",
|
|
" date 00:00:00 00:15:00 00:30:00 00:45:00 01:00:00 01:15:00 \\\n",
|
|
"0 2017-07-20 False False False False False False \n",
|
|
"1 2017-07-21 False False False False False False \n",
|
|
"2 2017-07-22 False False False True True False \n",
|
|
"3 2017-07-23 False False False False False False \n",
|
|
"4 2017-07-24 False True False False False False \n",
|
|
"... ... ... ... ... ... ... ... \n",
|
|
"36480 2020-06-09 False False True False False False \n",
|
|
"36481 2020-06-10 False False False False False False \n",
|
|
"36482 2020-06-11 False True False False False False \n",
|
|
"36483 2020-06-12 False False True False False False \n",
|
|
"36484 2020-06-13 False False True False False False \n",
|
|
"\n",
|
|
" 01:30:00 01:45:00 02:00:00 ... Month Year DayOfWeek_Friday \\\n",
|
|
"0 False False False ... 7 2017 False \n",
|
|
"1 False False False ... 7 2017 True \n",
|
|
"2 False False False ... 7 2017 False \n",
|
|
"3 False False False ... 7 2017 False \n",
|
|
"4 True False False ... 7 2017 False \n",
|
|
"... ... ... ... ... ... ... ... \n",
|
|
"36480 False False False ... 6 2020 False \n",
|
|
"36481 False False False ... 6 2020 False \n",
|
|
"36482 False False False ... 6 2020 False \n",
|
|
"36483 False False False ... 6 2020 True \n",
|
|
"36484 False False False ... 6 2020 False \n",
|
|
"\n",
|
|
" DayOfWeek_Monday DayOfWeek_Saturday DayOfWeek_Sunday \\\n",
|
|
"0 False False False \n",
|
|
"1 False False False \n",
|
|
"2 False True False \n",
|
|
"3 False False True \n",
|
|
"4 True False False \n",
|
|
"... ... ... ... \n",
|
|
"36480 False False False \n",
|
|
"36481 False False False \n",
|
|
"36482 False False False \n",
|
|
"36483 False False False \n",
|
|
"36484 False True False \n",
|
|
"\n",
|
|
" DayOfWeek_Thursday DayOfWeek_Tuesday DayOfWeek_Wednesday user \n",
|
|
"0 True False False 0 \n",
|
|
"1 False False False 0 \n",
|
|
"2 False False False 0 \n",
|
|
"3 False False False 0 \n",
|
|
"4 False False False 0 \n",
|
|
"... ... ... ... ... \n",
|
|
"36480 False True False 31 \n",
|
|
"36481 False False True 31 \n",
|
|
"36482 True False False 31 \n",
|
|
"36483 False False False 31 \n",
|
|
"36484 False False False 31 \n",
|
|
"\n",
|
|
"[36485 rows x 107 columns]\n"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"source": [
|
|
"FINAL CODE OF 1HR WITH THRESHOLD"
|
|
],
|
|
"metadata": {
|
|
"id": "Sab7rXWDKuvJ"
|
|
}
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"source": [
|
|
"import pandas as pd\n",
|
|
"\n",
|
|
"def process_file(file_path, user_label):\n",
|
|
" # Load the dataset\n",
|
|
" df = pd.read_csv(file_path, delimiter=';')\n",
|
|
"\n",
|
|
" # Step 1: Filter for iPhone devices\n",
|
|
" iphone_df = df[df['device'].str.contains('iPhone', na=False)] # Treat NaN as False\n",
|
|
"\n",
|
|
" # Step 2: Select the desired columns\n",
|
|
" result = iphone_df[['startDate', 'endDate', 'value']]\n",
|
|
"\n",
|
|
" # Step 3: Convert startDate to datetime\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"\n",
|
|
" # Step 4: Round down the startDate to the nearest 1-hour interval\n",
|
|
" iphone_df['1hr_interval'] = iphone_df['startDate'].dt.floor('H')\n",
|
|
"\n",
|
|
" # Step 5: Extract date and time\n",
|
|
" iphone_df['date'] = iphone_df['1hr_interval'].dt.date\n",
|
|
" iphone_df['time'] = iphone_df['1hr_interval'].dt.time\n",
|
|
"\n",
|
|
" # Step 6: Group by date and time, then sum the values for 1-hour intervals\n",
|
|
" iphone_df_filtered = iphone_df[iphone_df['value'] > 25].dropna(subset=['value'])\n",
|
|
" interval_sum = iphone_df.groupby(['date', 'time'])['value'].sum().reset_index()\n",
|
|
"\n",
|
|
" # Step 7: Pivot the data to get one row per day with columns for each 1-hour interval\n",
|
|
" pivot_table = interval_sum.pivot(index='date', columns='time', values='value').fillna(0)\n",
|
|
"\n",
|
|
" # Step 8: Create a full range of 1-hour intervals (00:00:00 to 23:00:00)\n",
|
|
" full_time_range = pd.date_range('00:00', '23:00', freq='H').time\n",
|
|
"\n",
|
|
" # Step 9: Reindex to include all possible 1-hour intervals and fill missing values with 0\n",
|
|
" pivot_table = pivot_table.reindex(columns=full_time_range, fill_value=0)\n",
|
|
"\n",
|
|
" # Step 10: Rename columns to reflect 1-hour intervals\n",
|
|
" pivot_table.columns = [f'{str(col)}' for col in pivot_table.columns]\n",
|
|
"\n",
|
|
" # Step 11: Reset index to have 'date' as a column instead of an index\n",
|
|
" pivot_table.reset_index(inplace=True)\n",
|
|
"\n",
|
|
" # Step 12: Add day of the week, month, and year columns\n",
|
|
" pivot_table['DayOfWeek'] = pd.to_datetime(pivot_table['date']).dt.day_name()\n",
|
|
" pivot_table['Month'] = pd.to_datetime(pivot_table['date']).dt.month\n",
|
|
" pivot_table['Year'] = pd.to_datetime(pivot_table['date']).dt.year\n",
|
|
"\n",
|
|
" # Step 13: One-hot encode the 'DayOfWeek' column\n",
|
|
" pivot_table = pd.concat([pivot_table, pd.get_dummies(pivot_table['DayOfWeek'], prefix='DayOfWeek')], axis=1)\n",
|
|
"\n",
|
|
" # Step 14: Convert 1-hour interval values to binary (True if > 0, else False)\n",
|
|
" for col in pivot_table.columns[1:25]: # Skip the 'date' column and focus on 1-hour intervals\n",
|
|
" pivot_table[col] = pivot_table[col].apply(lambda x: True if x > 0 else False)\n",
|
|
"\n",
|
|
" # Step 15: Add 'user' column with the specified user label\n",
|
|
" pivot_table['user'] = user_label\n",
|
|
"\n",
|
|
" # Print which file is currently being processed\n",
|
|
" print(f\"Processing file: {file_path}, User label: {user_label}\")\n",
|
|
"\n",
|
|
" # Step 16: Drop the 'DayOfWeek' column as it has been one-hot encoded\n",
|
|
" pivot_table.drop(columns=['DayOfWeek'], inplace=True)\n",
|
|
"\n",
|
|
" return pivot_table\n",
|
|
"\n",
|
|
"# List of files to skip\n",
|
|
"files_to_skip = {'StepCount06.csv','StepCount10.csv','StepCount12.csv', 'StepCount13.csv', 'StepCount15.csv', 'StepCount17.csv',\n",
|
|
" 'StepCount18.csv', 'StepCount20.csv', 'StepCount24.csv', 'StepCount27.csv','StepCount31.csv','StepCount32.csv',\n",
|
|
" 'StepCount42.csv', 'StepCount46.csv'}\n",
|
|
"\n",
|
|
"# Generate file paths, skipping specified files\n",
|
|
"file_paths = [f'/content/drive/My Drive/Data/iOS/StepCount{i:02d}.csv' for i in range(1, 47)\n",
|
|
" if f'StepCount{i:02d}.csv' not in files_to_skip]\n",
|
|
"\n",
|
|
"# Generate user labels based on file index\n",
|
|
"user_labels = list(range(len(file_paths)))\n",
|
|
"\n",
|
|
"# Process each file with its corresponding user label and concatenate the results\n",
|
|
"processed_dfs = [process_file(file_path, user_label) for file_path, user_label in zip(file_paths, user_labels)]\n",
|
|
"combined_df = pd.concat(processed_dfs, ignore_index=True)\n",
|
|
"\n",
|
|
"# Save the combined DataFrame to a new Excel file\n",
|
|
"updated_file_path = '/content/combined_aggregated_data_1hr_withthreshold.xlsx'\n",
|
|
"combined_df.to_excel(updated_file_path, index=False)\n",
|
|
"\n",
|
|
"# Print the final DataFrame\n",
|
|
"print(combined_df)\n"
|
|
],
|
|
"metadata": {
|
|
"id": "ovDzbhzW6GQX",
|
|
"colab": {
|
|
"base_uri": "https://localhost:8080/"
|
|
},
|
|
"outputId": "024b89fb-6990-4b8c-b69f-9bfa27f0ce5e",
|
|
"collapsed": true
|
|
},
|
|
"execution_count": null,
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-8-ae3c61a191b5>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['1hr_interval'] = iphone_df['startDate'].dt.floor('H')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['1hr_interval'].dt.date\n",
|
|
"<ipython-input-8-ae3c61a191b5>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['1hr_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount01.csv, User label: 0\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-8-ae3c61a191b5>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['1hr_interval'] = iphone_df['startDate'].dt.floor('H')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['1hr_interval'].dt.date\n",
|
|
"<ipython-input-8-ae3c61a191b5>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['1hr_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount02.csv, User label: 1\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount03.csv, User label: 2\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount04.csv, User label: 3\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-8-ae3c61a191b5>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['1hr_interval'] = iphone_df['startDate'].dt.floor('H')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['1hr_interval'].dt.date\n",
|
|
"<ipython-input-8-ae3c61a191b5>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['1hr_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount05.csv, User label: 4\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount07.csv, User label: 5\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-8-ae3c61a191b5>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['1hr_interval'] = iphone_df['startDate'].dt.floor('H')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['1hr_interval'].dt.date\n",
|
|
"<ipython-input-8-ae3c61a191b5>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['1hr_interval'].dt.time\n",
|
|
"<ipython-input-8-ae3c61a191b5>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['1hr_interval'] = iphone_df['startDate'].dt.floor('H')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['1hr_interval'].dt.date\n",
|
|
"<ipython-input-8-ae3c61a191b5>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['1hr_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount08.csv, User label: 6\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount09.csv, User label: 7\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount11.csv, User label: 8\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount14.csv, User label: 9\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount16.csv, User label: 10\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount19.csv, User label: 11\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount21.csv, User label: 12\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount22.csv, User label: 13\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-8-ae3c61a191b5>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['1hr_interval'] = iphone_df['startDate'].dt.floor('H')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['1hr_interval'].dt.date\n",
|
|
"<ipython-input-8-ae3c61a191b5>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['1hr_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount23.csv, User label: 14\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-8-ae3c61a191b5>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['1hr_interval'] = iphone_df['startDate'].dt.floor('H')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['1hr_interval'].dt.date\n",
|
|
"<ipython-input-8-ae3c61a191b5>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['1hr_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount25.csv, User label: 15\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount26.csv, User label: 16\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-8-ae3c61a191b5>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['1hr_interval'] = iphone_df['startDate'].dt.floor('H')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['1hr_interval'].dt.date\n",
|
|
"<ipython-input-8-ae3c61a191b5>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['1hr_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount28.csv, User label: 17\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount29.csv, User label: 18\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount30.csv, User label: 19\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-8-ae3c61a191b5>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['1hr_interval'] = iphone_df['startDate'].dt.floor('H')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['1hr_interval'].dt.date\n",
|
|
"<ipython-input-8-ae3c61a191b5>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['1hr_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount33.csv, User label: 20\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount34.csv, User label: 21\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount35.csv, User label: 22\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount36.csv, User label: 23\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-8-ae3c61a191b5>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['1hr_interval'] = iphone_df['startDate'].dt.floor('H')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['1hr_interval'].dt.date\n",
|
|
"<ipython-input-8-ae3c61a191b5>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['1hr_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount37.csv, User label: 24\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-8-ae3c61a191b5>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['1hr_interval'] = iphone_df['startDate'].dt.floor('H')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['1hr_interval'].dt.date\n",
|
|
"<ipython-input-8-ae3c61a191b5>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['1hr_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount38.csv, User label: 25\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount39.csv, User label: 26\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-8-ae3c61a191b5>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['1hr_interval'] = iphone_df['startDate'].dt.floor('H')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['1hr_interval'].dt.date\n",
|
|
"<ipython-input-8-ae3c61a191b5>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['1hr_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount40.csv, User label: 27\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stderr",
|
|
"text": [
|
|
"<ipython-input-8-ae3c61a191b5>:14: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['startDate'] = pd.to_datetime(iphone_df['startDate'], format='%Y-%m-%d %H:%M:%S %z')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:17: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['1hr_interval'] = iphone_df['startDate'].dt.floor('H')\n",
|
|
"<ipython-input-8-ae3c61a191b5>:20: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['date'] = iphone_df['1hr_interval'].dt.date\n",
|
|
"<ipython-input-8-ae3c61a191b5>:21: SettingWithCopyWarning: \n",
|
|
"A value is trying to be set on a copy of a slice from a DataFrame.\n",
|
|
"Try using .loc[row_indexer,col_indexer] = value instead\n",
|
|
"\n",
|
|
"See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
|
|
" iphone_df['time'] = iphone_df['1hr_interval'].dt.time\n"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"name": "stdout",
|
|
"text": [
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount41.csv, User label: 28\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount43.csv, User label: 29\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount44.csv, User label: 30\n",
|
|
"Processing file: /content/drive/My Drive/Data/iOS/StepCount45.csv, User label: 31\n",
|
|
" date 00:00:00 01:00:00 02:00:00 03:00:00 04:00:00 05:00:00 \\\n",
|
|
"0 2017-07-20 False False False False False False \n",
|
|
"1 2017-07-21 False False False False False False \n",
|
|
"2 2017-07-22 True True False False False False \n",
|
|
"3 2017-07-23 False False False False False False \n",
|
|
"4 2017-07-24 True True False False False False \n",
|
|
"... ... ... ... ... ... ... ... \n",
|
|
"36480 2020-06-09 True False False False False False \n",
|
|
"36481 2020-06-10 False False True False False False \n",
|
|
"36482 2020-06-11 True False False False False False \n",
|
|
"36483 2020-06-12 True False False False False False \n",
|
|
"36484 2020-06-13 True False False False False False \n",
|
|
"\n",
|
|
" 06:00:00 07:00:00 08:00:00 ... Month Year DayOfWeek_Friday \\\n",
|
|
"0 False False False ... 7 2017 False \n",
|
|
"1 False True True ... 7 2017 True \n",
|
|
"2 False True True ... 7 2017 False \n",
|
|
"3 False False True ... 7 2017 False \n",
|
|
"4 False False True ... 7 2017 False \n",
|
|
"... ... ... ... ... ... ... ... \n",
|
|
"36480 False False False ... 6 2020 False \n",
|
|
"36481 False False False ... 6 2020 False \n",
|
|
"36482 True True True ... 6 2020 False \n",
|
|
"36483 False False False ... 6 2020 True \n",
|
|
"36484 False False False ... 6 2020 False \n",
|
|
"\n",
|
|
" DayOfWeek_Monday DayOfWeek_Saturday DayOfWeek_Sunday \\\n",
|
|
"0 False False False \n",
|
|
"1 False False False \n",
|
|
"2 False True False \n",
|
|
"3 False False True \n",
|
|
"4 True False False \n",
|
|
"... ... ... ... \n",
|
|
"36480 False False False \n",
|
|
"36481 False False False \n",
|
|
"36482 False False False \n",
|
|
"36483 False False False \n",
|
|
"36484 False True False \n",
|
|
"\n",
|
|
" DayOfWeek_Thursday DayOfWeek_Tuesday DayOfWeek_Wednesday user \n",
|
|
"0 True False False 0 \n",
|
|
"1 False False False 0 \n",
|
|
"2 False False False 0 \n",
|
|
"3 False False False 0 \n",
|
|
"4 False False False 0 \n",
|
|
"... ... ... ... ... \n",
|
|
"36480 False True False 31 \n",
|
|
"36481 False False True 31 \n",
|
|
"36482 True False False 31 \n",
|
|
"36483 False False False 31 \n",
|
|
"36484 False False False 31 \n",
|
|
"\n",
|
|
"[36485 rows x 35 columns]\n"
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"source": [],
|
|
"metadata": {
|
|
"id": "6MLHoHlckLYk"
|
|
},
|
|
"execution_count": null,
|
|
"outputs": []
|
|
}
|
|
]
|
|
}
|