Skip to content

Added hourofyear for pivoting calcualtions #2052

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
wants to merge 1 commit into from
Closed

Added hourofyear for pivoting calcualtions #2052

wants to merge 1 commit into from

Conversation

timmie
Copy link
Contributor

@timmie timmie commented Oct 10, 2012

I do not know if this is possible. But very much needed.

@changhiskhan
Copy link
Contributor

AFAIK hoy is not an existing field. We'd love to merge a complete PR if you can implement it and add a test case.
Thanks for the feedback. Please keep the feature requests/bug reports coming!

@timmie
Copy link
Contributor Author

timmie commented Oct 10, 2012

I am just trying to improve the pivoting of time series.

Especially:
#1953

and

#833 (#736)

But I feel quite lost as my array knowledge is limited.
Also:
Where's the source for

import pandas.lib as lib

?

@timmie
Copy link
Contributor Author

timmie commented Oct 11, 2012

I have now the required function, purely python:

def hoy_dtobj64(dt_obj64):
    """
    calculate hour of year for a 'datetime64[ns]' object
    """
    doy = dt_obj64.dayofyear
    second = ((doy-1)*3600*24 + dt_obj64.hour*3600 + 
                dt_obj64.minute*60+dt_obj64.second)
    hoy = (second / 3600) + 1

    return hoy

Where shall we place it?

As an additional property of the index?

@changhiskhan
Copy link
Contributor

You're almost there :)

the definition for Timestamp resides in pandas/src/datetime.pyx
you can add that method in a similar manner as dayofweek/dayofyear etc.

Finally you'll need a few test cases to be added in to pandas/tseries/tests/.

@timmie
Copy link
Contributor Author

timmie commented Oct 13, 2012

mmh.

I must admit, I do not understand the code in pandas/src/datetime.pyx

I would need a helping hand.

my pure python function above is much more understandable..

@ghost
Copy link

ghost commented Jul 29, 2013

stalled.

@ghost ghost closed this Jul 29, 2013
@timmie
Copy link
Contributor Author

timmie commented Jul 29, 2013

what means stalled?

@ghost
Copy link

ghost commented Jul 29, 2013

It means "inactive for a long time".

@timmie
Copy link
Contributor Author

timmie commented Jul 29, 2013

let's close it then:
#2183

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants