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

Feature Request - multiple series and start-time #6

Closed
romanme2 opened this issue Aug 29, 2023 · 9 comments
Closed

Feature Request - multiple series and start-time #6

romanme2 opened this issue Aug 29, 2023 · 9 comments

Comments

@romanme2
Copy link

Hi,

Thanks Phil for this great package. I was wondering if there was a way to have multiple series from the same route, and as an added bonus specify where the start time should begin. Right now I am using pd.merge_asof to merge columns together, but it would be extremely helpful to have it all done in one pull. Let me know if its possible with your package.

@philsv
Copy link
Owner

philsv commented Aug 29, 2023

Hi romanme,

thanks for the suggestion. I will think of a implemention for that. Maybe neext week I have some time for that. A bit busy right now. If you have a solution already feel free to PR and I will have a look.

@philsv
Copy link
Owner

philsv commented Sep 1, 2023

Please have a look at version 0.3.0 I added your requested changes:
97b8a1f

Is this it what you where looking for?

@romanme2
Copy link
Author

romanme2 commented Sep 1, 2023

I am having an issue with the code"start_date: str | none" TypeError: unsupported operand types for |: 'type' and 'NoneType'

@philsv
Copy link
Owner

philsv commented Sep 1, 2023

Sorry about that. Seems you are using python below 3.10, I got rid of the PEP604 union types. Should work in 0.3.1 now.

@romanme2
Copy link
Author

romanme2 commented Sep 2, 2023

Still getting this issue that is forcing me to restart the kernal. Thank you so much for implementing this feature!

Input In [17], in <cell line: 1>()
----> 1 from myeia.api import API

File ~/.local/lib/python3.8/site-packages/myeia/api.py:48, in
41 df.index = pd.to_datetime(df.index)
42 return df
45 def get_date_range(
46 start_date: Union[str, None] = None,
47 end_date: Union[str, None] = None,
---> 48 ) -> tuple[str, str]:
49 """
50 Helper function to get the start and end date for a given series.
51 """
52 if not start_date:

@philsv
Copy link
Owner

philsv commented Sep 4, 2023

Sorry for that rough update. Types issues should be fixed now in 0.3.2

@romanme2
Copy link
Author

romanme2 commented Sep 4, 2023

One more thing, I am getting this error. Any idea?

UnboundLocalError Traceback (most recent call last)
Input In [68], in <cell line: 6>()
2 import matplotlib.pyplot as plt
3 import myeia
----> 6 eia.get_series_via_route(
7 route="/petroleum/crd/crpdn",
8 series=["MCRFPP51",'MCRFPP51'],
9 frequency="monthly",
10 facet='product',
11 start_date="2021-01-01"
12 ,end_date="2021-01-31"
13 )

File ~/.local/lib/python3.8/site-packages/myeia/api.py:169, in API.get_series_via_route(self, route, series, frequency, facet, new_name, start_date, end_date)
166 elif facet == "seriesId":
167 df = base_df[["period", "value", "seriesDescription", "seriesId"]]
--> 169 df.reset_index(drop=True, inplace=True)
170 name = new_name if new_name != "" else df[df.columns[2]][0]
171 df.rename(columns={df.columns[1]: name}, inplace=True)

UnboundLocalError: local variable 'df' referenced before assignment

@philsv
Copy link
Owner

philsv commented Sep 4, 2023

Your trying to get monthly data within a month? That does not make sense.

Try e.g.
facet='series',
start_date="2021-01-01"
end_date="2021-02-31"

and it should work, otherwise you will just get an empty dataframe back, as there are no data.

@romanme2
Copy link
Author

romanme2 commented Sep 5, 2023

Works great! Thank you for this wonderful python package!.

@romanme2 romanme2 closed this as completed Sep 5, 2023
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