-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
POC: pass date_unit to values_for_json #54198
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
Changes from all commits
e9d3e48
511a48a
1c0c710
01a53f1
101c612
f021ef9
ac727ca
8c2e193
51b443b
540deee
adfa01f
f167999
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -720,7 +720,25 @@ void PdBlock_iterBegin(JSOBJ _obj, JSONTypeContext *tc) { | |
return; | ||
} | ||
|
||
arrays = get_sub_attr(obj, "_mgr", "column_arrays"); | ||
NPY_DATETIMEUNIT dunit = ((PyObjectEncoder *)tc)->datetimeUnit; | ||
char *date_unit; | ||
if (dunit == NPY_FR_s) { | ||
date_unit = "s"; | ||
} else if (dunit == NPY_FR_ms) { | ||
date_unit = "ms"; | ||
} else if (dunit == NPY_FR_us) { | ||
date_unit = "us"; | ||
} else if (dunit == NPY_FR_ns) { | ||
date_unit = "ns"; | ||
} | ||
|
||
PyObject *mgr = PyObject_GetAttrString(obj, "_mgr"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There might be some code segments that hit this but don't have a _mgr attr. This would return NULL and could explain the segfaults So you will want to check if the result is equal to NULL and return an appropriate error message There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will update, but we only get here with a DataFrame. |
||
if (mgr == NULL) { | ||
return; | ||
} | ||
arrays = PyObject_CallMethod(mgr, "column_arrays", "%s", date_unit); | ||
Py_DECREF(mgr); | ||
|
||
if (!arrays) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After you are done with |
||
GET_TC(tc)->iterNext = NpyArr_iterNextNone; | ||
return; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you want to do here is create a Python object from the literal string, so
PyUnicode_FromString("s")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore this comment if you change L730 to
PyObject_CallMethod
- in that case you can just declaredate_unit
as achar *
and call it a day