BUG: ipmt not working with numpy==1.26.4 when using a pandas df as input.
Maintainer thường phản hồi trong vòng 3 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Tái hiện ví dụ với numpy 1.26.4 và pandas 2.2.1, sau đó kiểm tra numpy_financial/_financial.py xung quanh ipmt, đặc biệt là lệnh gọi np.where đang gây lỗi. So sánh các đầu vào là cột pandas với ví dụ mảng đã thay đổi hình dạng đang hoạt động; được xem là hoàn tất khi ipmt chấp nhận các cột DataFrame đã báo cáo mà không phát sinh ngoại lệ và giữ nguyên kết quả mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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:
import pandas as pd
import numpy_financial as npf
import numpy as np
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]})
#ValueError
npf.ipmt(df['rate'], df['periods'], df['nper'], df['pv'])
#Works
npf.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 pass
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.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
- Ngôn ngữ chính
- Python
- Star
- 414
- Fork
- 106
- Merge trung bình
- 2 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của numpy/numpy-financial
-
An integer `rate` truncates `fv` to an integer and makes `ipmt`/`ppmt` raiseCó thể đã có người làm @naseweisssss đã nhận 9 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
numpy/numpy-financial#166 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Add CUMPRINC and CUMIPMT functionsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởenhancement sustain-2026
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
numpy/numpy-financial#38 · 6 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
numpy/numpy-financial#131 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
DOC: Clarify the sign convention for fv in pmt documentation.Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởdocumentation sustain-2026
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
numpy/numpy-financial#130 · 8 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
BUG: rate returning incorrect valueCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
numpy/numpy-financial#126 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của numpy/numpy-financial
Issue tương tự
-
Context/namespace resources fail in-cluster: "Invalid kube-config file. No configuration found."Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
bug documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
awslabs/visual-asset-management-system#880 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
netbox status: needs owner type: documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
netbox-community/netbox#23533 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
app: scripts status: backlog type: documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
netbox-community/netbox-scripts#68 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
marin-community/marin#10765 ·
Maintainer thường phản hồi trong vòng 1 ngày