Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract first and last timestamp from input csv data #41

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/asleep/get_sleep.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def get_parsed_data(raw_data_path, info_data_path, resample_hz, args):
data = data.reset_index()

# apply time shift
start_time = pd.to_datetime(info['StartTime'])
end_time = pd.to_datetime(info['EndTime'])
start_time = pd.to_datetime(data['time'].iloc[0])
end_time = pd.to_datetime(data['time'].iloc[-1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This always overwrites the start and end time, even for the axivity device. Perhaps this should only be done for csv files.

Copy link
Member

@angerhang angerhang Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this PR still active?

Also, to avoid using magic numbers, we can name 0, and -1 as start_time_idx or end_time_idx.

info['StartTime'] = start_time + datetime.timedelta(hours=time_shift)
info['EndTime'] = end_time + datetime.timedelta(hours=time_shift)
info['StartTime'] = info['StartTime'].strftime('%Y-%m-%d %H:%M:%S')
Expand Down