File tree 2 files changed +9
-1
lines changed
2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -238,8 +238,9 @@ static PyObject *get_values(PyObject *obj) {
238
238
PyErr_Clear ();
239
239
} else if (PyObject_HasAttrString (values , "__array__" )) {
240
240
// We may have gotten a Categorical or Sparse array so call np.array
241
+ PyObject * array_values = PyObject_CallMethod (values , "__array__" , NULL );
241
242
Py_DECREF (values );
242
- values = PyObject_CallMethod ( values , "__array__" , NULL ) ;
243
+ values = array_values ;
243
244
} else if (!PyArray_CheckExact (values )) {
244
245
// Didn't get a numpy array, so keep trying
245
246
Py_DECREF (values );
Original file line number Diff line number Diff line change 23
23
DatetimeIndex ,
24
24
Index ,
25
25
NaT ,
26
+ PeriodIndex ,
26
27
Series ,
27
28
Timedelta ,
28
29
Timestamp ,
@@ -1240,3 +1241,9 @@ def test_encode_timedelta_iso(self, td):
1240
1241
expected = f'"{ td .isoformat ()} "'
1241
1242
1242
1243
assert result == expected
1244
+
1245
+ def test_encode_periodindex (self ):
1246
+ # GH 46683
1247
+ p = PeriodIndex (["2022-04-06" , "2022-04-07" ], freq = "D" )
1248
+ df = DataFrame (index = p )
1249
+ assert df .to_json () == "{}"
You can’t perform that action at this time.
0 commit comments