<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/tvyomkesh/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/tvyomkesh">@tvyomkesh</a> opened some issues (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="56145838" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/9384" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/9384/hovercard" href="https://github.com/pandas-dev/pandas/issues/9384">#9384</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="56168004" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/9389" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/9389/hovercard" href="https://github.com/pandas-dev/pandas/issues/9389">#9389</a>) on errors in the examples (and some PRs to fix this). This raised the following question to me:</p>
<p dir="auto">Apart from fixing the examples, I think we should think for a moment what we want to do with these examples. Why do we want them? What is their function?<br>
And depending on that, do we want to update/extend them? Or maybe move them to the docs?</p>
<p dir="auto">I personally never looked at these examples. And they are also quite outdated. Eg using the ols from pandas is somewhat (unofficially) deprecated for the use of statsmodels, and the finance module in matplotlib is deprecated starting from matplotlib 1.4. And to get such data, I think pandas-datareader should be used.</p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/jreback/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/jreback">@jreback</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/TomAugspurger/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/TomAugspurger">@TomAugspurger</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/shoyer/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/shoyer">@shoyer</a></p>
<p dir="auto"><code class="notranslate">DataFrame.from_dict</code> does not seem to behave <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.from_dict.html" rel="nofollow">according to the documentation</a>.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import pandas as pd

print(&quot;pandas.from_dict(&lt;dict&gt;, orient='index')&quot;)
print(pd.DataFrame.from_dict(dict([ ['key1', 1],['key2',2] ]), orient='index'))

print(&quot;pandas.from_dict(&lt;list [&lt;list&gt;]&gt;, orient='columns')&quot;)
print(pd.DataFrame.from_dict([ ['key1', 1],['key2',2] ], orient='columns'))

print(&quot;pandas.from_dict(&lt;dict&gt;, orient='columns')&quot;)
print(pd.DataFrame.from_dict(dict([ ['key1', 1],['key2',2] ]), orient='columns'))
"><pre class="notranslate"><code class="notranslate">import pandas as pd

print("pandas.from_dict(&lt;dict&gt;, orient='index')")
print(pd.DataFrame.from_dict(dict([ ['key1', 1],['key2',2] ]), orient='index'))

print("pandas.from_dict(&lt;list [&lt;list&gt;]&gt;, orient='columns')")
print(pd.DataFrame.from_dict([ ['key1', 1],['key2',2] ], orient='columns'))

print("pandas.from_dict(&lt;dict&gt;, orient='columns')")
print(pd.DataFrame.from_dict(dict([ ['key1', 1],['key2',2] ]), orient='columns'))

</code></pre></div>
<h4 dir="auto">Produces</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pandas.from_dict(&lt;dict&gt;, orient='index')
      0
key2  2
key1  1
pandas.from_dict(&lt;list [&lt;list&gt;]&gt;, orient='columns')
      0  1
0  key1  1
1  key2  2
pandas.from_dict(&lt;dict&gt;, orient='columns')
Traceback (most recent call last):
  File &quot;../../bin/pandaserr.py&quot;, line 10, in &lt;module&gt;
    print(pd.DataFrame.from_dict(dict([ ['key1', 1],['key2',2] ]), orient='columns'))
  File &quot;/home/cwarth/.local/lib/python2.7/site-packages/pandas/core/frame.py&quot;, line 804, in from_dict
    return cls(data, index=index, columns=columns, dtype=dtype)
  File &quot;/home/cwarth/.local/lib/python2.7/site-packages/pandas/core/frame.py&quot;, line 226, in __init__
    mgr = self._init_dict(data, index, columns, dtype=dtype)
  File &quot;/home/cwarth/.local/lib/python2.7/site-packages/pandas/core/frame.py&quot;, line 363, in _init_dict
    dtype=dtype)
  File &quot;/home/cwarth/.local/lib/python2.7/site-packages/pandas/core/frame.py&quot;, line 5158, in _arrays_to_mgr
    index = extract_index(arrays)
  File &quot;/home/cwarth/.local/lib/python2.7/site-packages/pandas/core/frame.py&quot;, line 5197, in extract_index
    raise ValueError('If using all scalar values, you must pass'
ValueError: If using all scalar values, you must pass an index"><pre class="notranslate"><code class="notranslate">pandas.from_dict(&lt;dict&gt;, orient='index')
      0
key2  2
key1  1
pandas.from_dict(&lt;list [&lt;list&gt;]&gt;, orient='columns')
      0  1
0  key1  1
1  key2  2
pandas.from_dict(&lt;dict&gt;, orient='columns')
Traceback (most recent call last):
  File "../../bin/pandaserr.py", line 10, in &lt;module&gt;
    print(pd.DataFrame.from_dict(dict([ ['key1', 1],['key2',2] ]), orient='columns'))
  File "/home/cwarth/.local/lib/python2.7/site-packages/pandas/core/frame.py", line 804, in from_dict
    return cls(data, index=index, columns=columns, dtype=dtype)
  File "/home/cwarth/.local/lib/python2.7/site-packages/pandas/core/frame.py", line 226, in __init__
    mgr = self._init_dict(data, index, columns, dtype=dtype)
  File "/home/cwarth/.local/lib/python2.7/site-packages/pandas/core/frame.py", line 363, in _init_dict
    dtype=dtype)
  File "/home/cwarth/.local/lib/python2.7/site-packages/pandas/core/frame.py", line 5158, in _arrays_to_mgr
    index = extract_index(arrays)
  File "/home/cwarth/.local/lib/python2.7/site-packages/pandas/core/frame.py", line 5197, in extract_index
    raise ValueError('If using all scalar values, you must pass'
ValueError: If using all scalar values, you must pass an index
</code></pre></div>
<p dir="auto">According to the reference documentation, "If the keys of the passed dict should be the columns of the resulting DataFrame, pass ‘columns’"  That doesn't appear to be what is happening.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto"><code class="notranslate">from_dict(&lt;dict&gt;, orient='index')</code> works as expected.<br>
I would expect <code class="notranslate">from_dict(..., orient='columns')</code> to return a  dataframe with the dictionary keys forming the column index, like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="      key1  key2
0   1        2"><pre class="notranslate"><code class="notranslate">      key1  key2
0   1        2
</code></pre></div>
<p dir="auto">I would expect  <code class="notranslate">from_dict()</code> to take a dict as a parameter in either case.   Instead it appears to take a a dict for <code class="notranslate">orient='index'</code> and a list of lists (or tuples) for <code class="notranslate">orient='columns'</code>.  Passing a dict with integer values when <code class="notranslate">orient='columns'</code> causes  a crash.</p>
<h4 dir="auto">output of <code class="notranslate">pd.show_versions()</code></h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="INSTALLED VERSIONS
------------------
commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-45-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.17.1
nose: 1.3.6
pip: 8.0.2
setuptools: 18.8
Cython: 0.23.2
numpy: 1.10.4
scipy: 0.15.1
statsmodels: 0.6.1
IPython: 4.0.3
sphinx: 1.2.3
patsy: 0.3.0
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: 3.1.1
numexpr: 2.2.2
matplotlib: 1.5.0
openpyxl: 2.2.0-b1
xlrd: 0.9.4
xlwt: 0.7.5
xlsxwriter: None
lxml: 3.3.3
bs4: 4.3.2
html5lib: 0.999
httplib2: 0.9
apiclient: None
sqlalchemy: 1.0.11
pymysql: None
psycopg2: None
Jinja2: None"><pre class="notranslate"><code class="notranslate">INSTALLED VERSIONS
------------------
commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-45-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.17.1
nose: 1.3.6
pip: 8.0.2
setuptools: 18.8
Cython: 0.23.2
numpy: 1.10.4
scipy: 0.15.1
statsmodels: 0.6.1
IPython: 4.0.3
sphinx: 1.2.3
patsy: 0.3.0
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: 3.1.1
numexpr: 2.2.2
matplotlib: 1.5.0
openpyxl: 2.2.0-b1
xlrd: 0.9.4
xlwt: 0.7.5
xlsxwriter: None
lxml: 3.3.3
bs4: 4.3.2
html5lib: 0.999
httplib2: 0.9
apiclient: None
sqlalchemy: 1.0.11
pymysql: None
psycopg2: None
Jinja2: None
</code></pre></div>