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

Vectorisation all casts to same datetime #10

Open
MLUY opened this issue Mar 22, 2023 · 1 comment
Open

Vectorisation all casts to same datetime #10

MLUY opened this issue Mar 22, 2023 · 1 comment

Comments

@MLUY
Copy link

MLUY commented Mar 22, 2023

Hi Kyle
First of all thanks for this great package!
I am having trouble to get the vectorization to work as per your example
I have a pandas date frame with a 'Date' column of (datetimes) and a long and lat (floats)
When I run the vector operation I am getting a single date back (ref attachment)

What could I be doing wrong?

Thanks a lot
Michiel

cast1969

@nyooc
Copy link
Contributor

nyooc commented Apr 18, 2023

Michiel,
I managed to reproduce your example. The problem is that your date series is TZ-naive and it should be TZ-aware. (And I understand the get_times() API should tell you this...) You can correct it for example by localizing it to a given timezone:

df['Date'] = df['Date'].dt.tz_localize('utc')

If you want a set up a local hourly date series for some place with a non-fixed UTC-offset (think DST changes), you might be better off with initializing your date series right away as a TZ-aware series, something like

df['Date'] = pd.date_range('1979-01-01', '2019-01-01', inclusive='left', freq='H', tz='Europe/Budapest')

Another remark, there will be one sunrise time per local day, so you'll computationally better off if you use a dataset with just a single observation per day.

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

No branches or pull requests

2 participants