Skip to content

Commit

Permalink
Updated time format with default
Browse files Browse the repository at this point in the history
  • Loading branch information
brinnaebent committed Jun 5, 2020
1 parent bfe28ef commit 837f18a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]',
keywords = ['wearables', 'features', 'feature engineering'],
Expand Down
10 changes: 6 additions & 4 deletions wearablevar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 837f18a

Please sign in to comment.