Skip to content

ENH: Canonic SI frequency #33524

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

Closed
JoElfner opened this issue Apr 13, 2020 · 3 comments
Closed

ENH: Canonic SI frequency #33524

JoElfner opened this issue Apr 13, 2020 · 3 comments

Comments

@JoElfner
Copy link
Contributor

Since pandas is widely used for data science, including working with time series, a canonic representation of the frequency, as defined by SI standards, physics etc. would be a nice improvement.

To summarize differences between the general definition of frequency and the pandas definition of frequency:

  • General definition: Frequency is in the unit of 1/time_period, for SI unis more specifically 1/second=1Hz.
  • pandas definition: Frequency is the time period, so it is exactly the opposite of the physical/general definition.

Since many calculations require the actual frequency, for example summing up velocities to get the length, this would facilitate many calculations.

Proposed solution:

Additionally pd.DatetimeIndex etc. should get a new attribute, f.i. named freq_canonic, that represents the actual frequency of the index in Hertz.

To avoid breaking the API, I'd implement the frequency as a data attribute, which can be accessed by the user, but has no effect on time series calculations.

I could try making a pull request for this feature, if you are interested.

@JoElfner JoElfner added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 13, 2020
@jbrockmendel
Copy link
Member

Is the DatetimeIndex attribute the main sticking point? Or do you need something like a Hertz dtype (which would be similar to #10349)?

@JoElfner
Copy link
Contributor Author

JoElfner commented Apr 14, 2020

Good question... :)
I guess if the Hertz dtype was added automatically during DatetimeIndex creation, it would be a really nice solution. But would it be possible to directly make some calculations with the Hertz dtype without the need for any conversions? Like f.i. velocity/Hertz_dtype?
If not, imho an attribute is quite important. F.i. a period/freq of '20s' would yield DatetimeIndex.freq_canonic as a float, in this case 0.05 (unit Hz: 1/s).

@jbrockmendel jbrockmendel removed the Needs Triage Issue that has not been reviewed by a pandas team member label Sep 3, 2020
@jbrockmendel
Copy link
Member

closing as no action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants