You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Operating System: Ubuntu (inside Windows Subsystem for Linux)
Description
In the usage example, faros_df lacks acceleration data in some rows (x, y, z components are NaN). However, returned magnitude for that rows is 0.0 and I would expect NaN. Is there a reason for that?
By default, the sum of an empty or all-NA Series is 0.
pd.Series([], dtype="float64").sum() # min_count=0 is the default
0.0
This can be controlled with the min_count parameter. For example, if you’d like the sum of an empty series to be NaN, pass min_count=1.
pd.Series([], dtype="float64").sum(min_count=1)
nan
Thus, I would modify np.sqrt(np.square(data).sum(axis=1)) in calculate_magnitude by np.sqrt(np.square(data).sum(axis=1, min_count=1)) or use np.linalg.norm(data, axis=1).
The text was updated successfully, but these errors were encountered:
Description
In the usage example,
faros_df
lacks acceleration data in some rows (x, y, z components are NaN). However, returned magnitude for that rows is 0.0 and I would expect NaN. Is there a reason for that?What I Did
Results in
7400 rows × 5 columns
Possible solution
According to
DataFrame.sum
method documetation (https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.sum.html)Thus, I would modify
np.sqrt(np.square(data).sum(axis=1))
incalculate_magnitude
bynp.sqrt(np.square(data).sum(axis=1, min_count=1))
or usenp.linalg.norm(data, axis=1)
.The text was updated successfully, but these errors were encountered: