<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# Your code here
data = [{'id': 11, 'text': 'Osv1wbZoL'},
        {'id': 0, 'text': 'KQpPReW3S9nZOS3'},
        {'id': 0, 'text': 'cbqLhjrb0B2Ah6E'},
        {'id': 3, 'text': 'qu1Jlnyba'},
        {'id': 14, 'text': 'aJUv5DBjbcGc3'},
        {'id': 12, 'text': 'Yobf9'},
        {'id': 4, 'text': 'awzZCV'},
        {'id': 4, 'text': '3NvBAVL'},
        {'id': 11, 'text': '80sPCxIf9s5wmEZ1'},
        {'id': 5, 'text': 'afrPD0X6mIzFK'}]

df = pd.DataFrame(data)
# out:
# id       int64
# text    object
# dtype: object

type(df[['id', 'text']].to_dict(orient='records')[0]['id'])
# out: int

type(df[['id']].to_dict(orient='records')[0]['id'])
# out: numpy.int64"><pre class="notranslate"><span class="pl-c"># Your code here</span>
<span class="pl-s1">data</span> <span class="pl-c1">=</span> [{<span class="pl-s">'id'</span>: <span class="pl-c1">11</span>, <span class="pl-s">'text'</span>: <span class="pl-s">'Osv1wbZoL'</span>},
        {<span class="pl-s">'id'</span>: <span class="pl-c1">0</span>, <span class="pl-s">'text'</span>: <span class="pl-s">'KQpPReW3S9nZOS3'</span>},
        {<span class="pl-s">'id'</span>: <span class="pl-c1">0</span>, <span class="pl-s">'text'</span>: <span class="pl-s">'cbqLhjrb0B2Ah6E'</span>},
        {<span class="pl-s">'id'</span>: <span class="pl-c1">3</span>, <span class="pl-s">'text'</span>: <span class="pl-s">'qu1Jlnyba'</span>},
        {<span class="pl-s">'id'</span>: <span class="pl-c1">14</span>, <span class="pl-s">'text'</span>: <span class="pl-s">'aJUv5DBjbcGc3'</span>},
        {<span class="pl-s">'id'</span>: <span class="pl-c1">12</span>, <span class="pl-s">'text'</span>: <span class="pl-s">'Yobf9'</span>},
        {<span class="pl-s">'id'</span>: <span class="pl-c1">4</span>, <span class="pl-s">'text'</span>: <span class="pl-s">'awzZCV'</span>},
        {<span class="pl-s">'id'</span>: <span class="pl-c1">4</span>, <span class="pl-s">'text'</span>: <span class="pl-s">'3NvBAVL'</span>},
        {<span class="pl-s">'id'</span>: <span class="pl-c1">11</span>, <span class="pl-s">'text'</span>: <span class="pl-s">'80sPCxIf9s5wmEZ1'</span>},
        {<span class="pl-s">'id'</span>: <span class="pl-c1">5</span>, <span class="pl-s">'text'</span>: <span class="pl-s">'afrPD0X6mIzFK'</span>}]

<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">data</span>)
<span class="pl-c"># out:</span>
<span class="pl-c"># id       int64</span>
<span class="pl-c"># text    object</span>
<span class="pl-c"># dtype: object</span>

<span class="pl-en">type</span>(<span class="pl-s1">df</span>[[<span class="pl-s">'id'</span>, <span class="pl-s">'text'</span>]].<span class="pl-en">to_dict</span>(<span class="pl-s1">orient</span><span class="pl-c1">=</span><span class="pl-s">'records'</span>)[<span class="pl-c1">0</span>][<span class="pl-s">'id'</span>])
<span class="pl-c"># out: int</span>

<span class="pl-en">type</span>(<span class="pl-s1">df</span>[[<span class="pl-s">'id'</span>]].<span class="pl-en">to_dict</span>(<span class="pl-s1">orient</span><span class="pl-c1">=</span><span class="pl-s">'records'</span>)[<span class="pl-c1">0</span>][<span class="pl-s">'id'</span>])
<span class="pl-c"># out: numpy.int64</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">depending on the count of output columns, numpy integers getting converted to python integers</p>
<p dir="auto">afterwards both <code class="notranslate">json.dumps</code> and <code class="notranslate">ujson.dumps</code> fails to encode</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">int for both cases</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.1.final.0
python-bits: 64
OS: Darwin
OS-release: 16.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
<p dir="auto">pandas: 0.19.2<br>
nose: 1.3.7<br>
pip: 9.0.1<br>
setuptools: 33.1.1.post20170320<br>
Cython: 0.25.2<br>
numpy: 1.12.1<br>
scipy: 0.19.0<br>
statsmodels: 0.8.0<br>
xarray: None<br>
IPython: 5.3.0<br>
sphinx: None<br>
patsy: 0.4.1<br>
dateutil: 2.6.0<br>
pytz: 2017.2<br>
blosc: None<br>
bottleneck: None<br>
tables: 3.3.0<br>
numexpr: 2.6.2<br>
matplotlib: 2.0.0<br>
openpyxl: None<br>
xlrd: None<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: None<br>
html5lib: 0.999<br>
httplib2: None<br>
apiclient: None<br>
sqlalchemy: 1.1.9<br>
pymysql: 0.7.10.None<br>
psycopg2: 2.6.2 (dt dec pq3 ext lo64)<br>
jinja2: 2.9.5<br>
boto: None<br>
pandas_datareader: None</p>
</details>
<p dir="auto">xref <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="155922105" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/13236" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/13236/hovercard" href="https://github.com/pandas-dev/pandas/issues/13236">#13236</a>  as <code class="notranslate">.map</code> was recently clarified to box ints/floats (and all other dtypes) to python/pandas types (rather than numpy scalars). <code class="notranslate">__iter__</code> should do the same (it already is done for datetimelikes), need to add for int/floats.</p>
<p dir="auto">Furthermore <code class="notranslate">Series.tolist()</code> also returns python types (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="103130382" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/10904" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/10904/hovercard" href="https://github.com/pandas-dev/pandas/issues/10904">#10904</a>)</p>
<p dir="auto">This will make it more consistent with pandas iteration strategy.</p>
<p dir="auto">We also already do this for <code class="notranslate">object</code> types</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [12]: type(list(Series([Timestamp('20130101'),Timestamp('20130101',tz='US/Eastern'),1,1.0,'foo']))[2])
Out[12]: int"><pre class="notranslate"><code class="notranslate">In [12]: type(list(Series([Timestamp('20130101'),Timestamp('20130101',tz='US/Eastern'),1,1.0,'foo']))[2])
Out[12]: int
</code></pre></div>
<p dir="auto">.tolist()</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [3]: type(Series([1,2,3]).tolist()[2])
Out[3]: int"><pre class="notranslate"><code class="notranslate">In [3]: type(Series([1,2,3]).tolist()[2])
Out[3]: int
</code></pre></div>
<p dir="auto">let's fix for pure types</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [14]: type(list(Series([1,2,3]))[2])
Out[14]: numpy.int64"><pre class="notranslate"><code class="notranslate">In [14]: type(list(Series([1,2,3]))[2])
Out[14]: numpy.int64
</code></pre></div>
<p dir="auto">When solving this issue, also have to look at:</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Inconsistent conversion in <code class="notranslate">to_dict</code> to numpy/python scalar (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="176776804" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/14216" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/14216/hovercard" href="https://github.com/pandas-dev/pandas/issues/14216">#14216</a>)</li>
</ul>