Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BUG: ipmt not working with numpy==1.26.4 when using a pandas df as input. #105

Open
Labels
bugSomething isn't workinghelp wantedExtra attention is needed
Milestone
@erikgrenestam

Description

@erikgrenestam

Describe the issue:

Not sure if bug or feature request, but I used to be able to use pandas dataframe columns as input arrays to npf.ipmt(). With numpy 1.26.4 and pandas 2.2.1 that yields a ValueError. I think it might be due to a change in np.broadcast_arrays()

Reproduce the code example:

importpandasaspdimportnumpy_financialasnpfimportnumpyasnpdf=pd.DataFrame({'rate': [0.05,0.07],'periods':[np.array([1,2,3,4]),np.array([1,2,3,4])],'pv': [10000,12000],'nper': [10,10]})#ValueErrornpf.ipmt(df['rate'],df['periods'],df['nper'],df['pv'])#Worksnpf.ipmt(np.array(df['rate'].tolist()).reshape(-1,1),np.array(df['periods'].tolist()),np.array(df['nper'].tolist()).reshape(-1,1),np.array(df['pv'].tolist()).reshape(-1,1))

Error message:

Traceback (most recent call last)Cell In[4], line 2      1 df = pd.DataFrame({'rate': [0.05, 0.07],'periods':[np.array([1,2,3,4]), np.array([1,2,3,4])],'pv': [10000, 12000],'nper': [10,10]})----> 2 npf.ipmt(df['rate'], df['periods'], df['nper'], df['pv'])File~\.conda\envs\test\Lib\site-packages\numpy_financial\_financial.py:394,in ipmt(rate, per, nper, pv, fv, when)    392 try:    393     ipmt = np.where(when == 1, ipmt/(1 + rate), ipmt)--> 394     ipmt = np.where(np.logical_and(when == 1, per == 1), 0, ipmt)    395 except IndexError:    396     passValueError: The truth value of an array with more than one element is ambiguous. Usea.any() ora.all()

Runtime information:

1.26.4
3.11.8 | packaged by Anaconda, Inc. | (main, Feb 26 2024, 21:34:05) [MSC v.1916 64 bit (AMD64)]

[{'numpy_version': '1.26.4',
'python': '3.11.8 | packaged by Anaconda, Inc. | (main, Feb 26 2024, '
'21:34:05) [MSC v.1916 64 bit (AMD64)]',
'uname': uname_result(system='Windows', node='xxx', release='10', version='10.0.19045', machine='AMD64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2'],
'not_found': ['AVX512F',
'AVX512CD',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL']}}]

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp