-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Support Series and DataFrame with DatetimeIndex #12
Comments
Hi @Peque, You can use the following code with the current implementation: # for Series
xirr(s.reset_index())
xirr(s.index, s)
# for DataFrame
df.apply(lambda col: xirr(col.reset_index()))
df.apply(lambda col: xirr(col.index, col) |
@Anexen Do you think it would make sense to return This would allow for In example: from pandas import DataFrame
from pandas import date_range
from pyxirr import xirr
timezone = "Europe/Madrid"
index = date_range("2000-01-01", periods=10, freq="Y", closed="left", tz=timezone)
df = DataFrame(index=index, data={"a": 10, "b": 10})
df.iloc[0]["a"] = -25
df.apply(xirr) Would return |
@Peque , I don't think so. I would like a clear separation between "Invalid input" case and "does not converge" case. You can use something like this: def suppress(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except InvalidPaymentsError:
return None
return wrapper
df.apply(suppress(xirr)) |
In example:
For the
DataFrame
I am suggesting returning aSeries
type simply because that is what i.e.df.sum()
would return (applying.sum()
to all columns).Feel free to close if is out of scope for this module! (I would understand that) 😊
The text was updated successfully, but these errors were encountered: