raulcd commented on code in PR #50465:
URL: https://github.com/apache/arrow/pull/50465#discussion_r3629316465
##########
python/pyarrow/src/arrow/python/arrow_to_pandas.cc:
##########
@@ -1292,24 +1292,11 @@ struct ObjectWriterVisitor {
auto to_date_offset = [&](const MonthDayNanoIntervalType::MonthDayNanos&
interval,
PyObject** out) {
ARROW_DCHECK(internal::BorrowPandasDataOffsetType() != nullptr);
- // DateOffset objects do not add nanoseconds component to pd.Timestamp.
- // as of Pandas 1.3.3
- // (https://github.com/pandas-dev/pandas/issues/43892).
- // So convert microseconds and remainder to preserve data
- // but give users more expected results.
- int64_t microseconds = interval.nanoseconds / 1000;
- int64_t nanoseconds;
- if (interval.nanoseconds >= 0) {
- nanoseconds = interval.nanoseconds % 1000;
- } else {
- nanoseconds = -((-interval.nanoseconds) % 1000);
- }
PyDict_SetItemString(kwargs.obj(), "months",
PyLong_FromLong(interval.months));
PyDict_SetItemString(kwargs.obj(), "days",
PyLong_FromLong(interval.days));
- PyDict_SetItemString(kwargs.obj(), "microseconds",
- PyLong_FromLongLong(microseconds));
- PyDict_SetItemString(kwargs.obj(), "nanoseconds",
PyLong_FromLongLong(nanoseconds));
+ PyDict_SetItemString(kwargs.obj(), "nanoseconds",
+ PyLong_FromLongLong(interval.nanoseconds));
Review Comment:
ah! I understand you now. Yes the single `RETURN_IF_PYERROR` after all
`PyDict_SetItemString` is what I wasn't sure. Thanks for confirming.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]