Skip to content

Output type is float for steps column in Oak CSVs #226

@biblicabeebli

Description

@biblicabeebli

I believe the issue where steps is output as a float is the following line:

steps_daily = np.full((len(days), 1), np.nan)

I'm not fluent in numpy to really be sure, but I do know that nan implies a floating point type (its a float-only concept), and the array is by construction one type.\

I tried the following change:

summary_stats = pd.DataFrame({
                    'date': days.strftime('%Y-%m-%d'),
                    'walking_time': walkingtime_daily[:, -1],
                    'steps': steps_daily[:, -1].astype(int),
                    'cadence': cadence_daily[:, -1]})

but this emits the runtime warning
RuntimeWarning: invalid value encountered in cast 'steps': steps_daily[:, -1].astype(int),

Changing the declaration like this fixes that message

steps_daily = np.full((len(days), 1), 0) 

But this officially puts me in "I don't know if this has side effects" territory.

(I'm currently ignoring the separate code path in here for hourly steps, but I assume the same change applies there.)

This is all in oak.base.run

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions