Hello,
Thank you for this!
Would be happy if I could input a pandas series with datetime64 format / datetime index and get the settlement period pandas series as an output. Perhaps there could be a more efficient way to handle a long time series other than running .apply to every row.
With the current implementation, such effect can be (inefficiently) achieved like so:
from sp2ts import ts2sp, to_unixtime
df["datetime"] = pd.to_datetime(
df.index, utc=True
).tz_convert("Europe/London")
# Convert the datetime column to Unix time using a vectorized operation
unix_times = df["datetime"].apply(to_unixtime)
# Apply the ts2sp function to the entire Unix time series at once
dates, settlement_periods = zip(*unix_times.apply(ts2sp))
df["date"] = dates
df["sp"] = settlement_periods
Hello,
Thank you for this!
Would be happy if I could input a pandas series with datetime64 format / datetime index and get the settlement period pandas series as an output. Perhaps there could be a more efficient way to handle a long time series other than running
.applyto every row.With the current implementation, such effect can be (inefficiently) achieved like so: