From 837f18aa1ec6942566c5d97713d5199180dfdd51 Mon Sep 17 00:00:00 2001 From: brinnaebent Date: Fri, 5 Jun 2020 16:53:13 -0400 Subject: [PATCH] Updated time format with default --- setup.py | 4 ++-- wearablevar/__init__.py | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 225bbbf..f56ef8c 100644 --- a/setup.py +++ b/setup.py @@ -2,10 +2,10 @@ setup(name='wearablevar', packages = ['wearablevar'], - version='0.1', + version='0.2', description='Variability Metrics from Longitudinal Wearable Sensors', url='https://github.com/brinnaebent/wearablevar', - download_url = 'https://github.com/brinnaebent/wearablevar/archive/0.1.tar.gz', + download_url = 'https://github.com/brinnaebent/wearablevar/archive/0.2.tar.gz', author='Brinnae Bent', author_email='runsdata@gmail.com', keywords = ['wearables', 'features', 'feature engineering'], diff --git a/wearablevar/__init__.py b/wearablevar/__init__.py index e9cdad2..3479c35 100644 --- a/wearablevar/__init__.py +++ b/wearablevar/__init__.py @@ -29,30 +29,32 @@ ''' -def importe4(filename): +def importe4(filename, f = '%Y-%m-%d %H:%M:%S.%f'): """ Function for importing and formatting for use with other functions. Args: filename (string): filename to a .csv with 2 columns - one with time in format = '%Y-%m-%d %H:%M:%S.%f', and the other column being the sensor value + f (string): Datetime format of .csv Returns: df (pandas.DataFrame): """ df = pd.read_csv(filename, header=None, names=['Time', 'Sensor']) - df['Time'] = pd.to_datetime(df['Time'], format='%Y-%m-%d %H:%M:%S.%f') + df['Time'] = pd.to_datetime(df['Time'], format=f) df['Day'] = df['Time'].dt.date df = df.reset_index() return df -def importe4acc(filename): +def importe4acc(filename, f = '%Y-%m-%d %H:%M:%S.%f'): """ Function for importing and formatting for use with other functions. Args: filename (string): filename to a .csv with 4 columns - one with time in format = '%Y-%m-%d %H:%M:%S.%f', and the other columns being x,y,z of tri-axial accelerometry + f (string): Datetime format of .csv Returns: df (pandas.DataFrame): """ df = pd.read_csv(filename, header=None, names=['Time', 'X', 'Y', 'Z']) - df['Time'] = pd.to_datetime(df['Time'], format='%Y-%m-%d %H:%M:%S.%f') + df['Time'] = pd.to_datetime(df['Time'], format=f) df['Day'] = df['Time'].dt.date df['ri'] = np.sqrt(df['X']**2 + df['Y']**2 + df['Z']**2) df['Sensor'] = df['ri'] - 64