SeitaBV / timely-beliefs

Model data as beliefs (at a certain time) about events (at a certain time).
MIT License
33 stars 6 forks source link

BeliefsDataFrame initialization with pd.Series fails if serie has a name #64

Open nhoening opened 3 years ago

nhoening commented 3 years ago

In this line, TB will use the name of the series if it has one instead of event_value, but then fail later on because the resulting BeliefsDataFrame requires a column of that name.

I propose we drop names of such series if they are argument 0.

P.S. It could be documented a bit clearer that you use a kw arg beliefs for initialization method 1, but non-kw args for method 2 & 3.

Flix6x commented 3 years ago

Can you please add a short example to help me investigate?

nhoening commented 3 years ago

In our flexmeasures-entsoe plugin, I am using the function client.query_generation_forecast from entsoe-py. It returns a pd.Series with a name.

Then I want to create a BeliefsDataFrame from that series:

bdf = BeliefsDataFrame(
     series,
     source=data_source,
     sensor=sensor,
     belief_time=now,
)

This created an error.

I worked around that error by adding this line before the BDF creation:

series.name = "event_value"

Setting it to None would also have worked.

Hope that helps.

nhoening commented 1 year ago

Bump: Could this be something we get into the next release? I could imagine it's a one-liner. I could also do this, but @Flix6x, you said you want to investigate, as well.

Flix6x commented 1 year ago

It should be a simple fix indeed, I just didn't get around to it. Feel free to submit a PR.