Skip to content

Tech 182 python sdk users want an example with historic monthly data#37

Merged
alex-solcast merged 10 commits into
Solcast:mainfrom
billy-solcast:TECH-182-python-sdk-users-want-an-example-with-historic-monthly-data
Jul 4, 2024
Merged

Tech 182 python sdk users want an example with historic monthly data#37
alex-solcast merged 10 commits into
Solcast:mainfrom
billy-solcast:TECH-182-python-sdk-users-want-an-example-with-historic-monthly-data

Conversation

@billy-solcast

Copy link
Copy Markdown
Contributor

Updated example historic request to include multi period request

billy-solcast and others added 6 commits June 26, 2024 15:57
…ly temporary until the SDK can automatically call the specific month in the array to complete the requests.
Removed due to not necessary for required task.
Remove as not necessary to provide example of multi month request

@billy-solcast billy-solcast left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be all that is changed within the pull request.

Did not include an example table as it should be the same as the file above.

@Zempire Zempire left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense but one issue i can see is that you might get more than 356 days, i.e. 31 * 11 get you to 341, so the last iteration would add 31 to that giving you 372 days. Not a problem at this point but could lead to errors if those extra days were in live/forecast range.

However cant think of a simple solution for you as duration forces each request to be that length.

Comment thread docs/historic.md Outdated
Comment thread docs/historic.md Outdated
Comment thread docs/historic.md Outdated
Comment thread docs/historic.md Outdated
Comment thread docs/historic.md Outdated
…-monthly-data' of https://github.com/billy-solcast/solcast-api-python-sdk into TECH-182-python-sdk-users-want-an-example-with-historic-monthly-data
Updated the end date timestamp as it was incorrectly hardcoded to 11am instead of 11pm.
Also removed the ignore index as the date range was incorrectly removed from the output.
@alex-solcast alex-solcast merged commit 6cb4eea into Solcast:main Jul 4, 2024
Comment thread docs/historic.md
Comment thread docs/historic.md
Comment thread docs/historic.md
Comment thread docs/historic.md
Comment thread docs/historic.md
Comment thread docs/historic.md
Comment thread docs/historic.md
Comment thread docs/historic.md
Comment thread docs/historic.md
start_date = '2023-01-01'
start_dates = pd.date_range(start=start_date, periods=12, freq='MS')

for start in start_dates:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I liked about your previous implementation with while loop, is that it did not require the user to think up front about how the queries should be chunked.

The following version of the former while code will only get the exact number of days required (including getting all of the final day).

step = 31
while days < days_required:
    chunk_start = start + pd.DateOffset(days=days)
    duration_days = min(step, days_required - days + 1)
    res = historic.radiation_and_weather(latitude=-33.856784, longitude=151.215297, start=chunk_start, duration=f'P{duration_days}D')
    responses.append(res)
    days += step

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was updated as a solution to @Zempire's comment:
#37 (review)

I think it's a cleaner way to pull the data, if the final objective is to retrieve only one years worth of data.

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.

4 participants