Skip to content

Commit dcf4ff9

Browse files
committed
BUG: fix ujson handling of new series object
1 parent 9e6175e commit dcf4ff9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pandas/io/tests/test_json/test_ujson.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,6 @@ def testSeries(self):
11501150
s = Series([10, 20, 30, 40, 50, 60], name="series", index=[6,7,8,9,10,15])
11511151
s.sort()
11521152

1153-
import pdb; pdb.set_trace()
11541153
# column indexed
11551154
outp = Series(ujson.decode(ujson.encode(s)))
11561155
outp.sort()

pandas/src/ujson/python/objToJSON.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,11 +1387,13 @@ void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc)
13871387
return;
13881388
}
13891389

1390+
pc->newObj = PyObject_GetAttrString(obj, "values");
1391+
13901392
if (enc->outputFormat == INDEX || enc->outputFormat == COLUMNS)
13911393
{
13921394
PRINTMARK();
13931395
tc->type = JT_OBJECT;
1394-
pc->columnLabelsLen = PyArray_SIZE(obj);
1396+
pc->columnLabelsLen = PyArray_DIM(pc->newObj, 0);
13951397
pc->columnLabels = NpyArr_encodeLabels((PyArrayObject*) PyObject_GetAttrString(obj, "index"), (JSONObjectEncoder*) enc, pc->columnLabelsLen);
13961398
if (!pc->columnLabels)
13971399
{
@@ -1403,7 +1405,6 @@ void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc)
14031405
PRINTMARK();
14041406
tc->type = JT_ARRAY;
14051407
}
1406-
pc->newObj = PyObject_GetAttrString(obj, "values");
14071408
pc->iterBegin = NpyArr_iterBegin;
14081409
pc->iterEnd = NpyArr_iterEnd;
14091410
pc->iterNext = NpyArr_iterNext;

0 commit comments

Comments
 (0)