Skip to content

DOC: remove deprecated from_items from dsintro docs #19837

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

Merged
merged 4 commits into from
Feb 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 13 additions & 22 deletions doc/source/dsintro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,19 @@ and returns a DataFrame. It operates like the ``DataFrame`` constructor except
for the ``orient`` parameter which is ``'columns'`` by default, but which can be
set to ``'index'`` in order to use the dict keys as row labels.


.. ipython:: python

pd.DataFrame.from_dict(dict([('A', [1, 2, 3]), ('B', [4, 5, 6])]))

If you pass ``orient='index'``, the keys will be the row labels. In this
case, you can also pass the desired column names:

.. ipython:: python

pd.DataFrame.from_dict(dict([('A', [1, 2, 3]), ('B', [4, 5, 6])]),
orient='index', columns=['one', 'two', 'three'])

.. _basics.dataframe.from_records:

**DataFrame.from_records**
Expand All @@ -378,28 +391,6 @@ dtype. For example:
data
pd.DataFrame.from_records(data, index='C')

.. _basics.dataframe.from_items:

**DataFrame.from_items**

``DataFrame.from_items`` works analogously to the form of the ``dict``
constructor that takes a sequence of ``(key, value)`` pairs, where the keys are
column (or row, in the case of ``orient='index'``) names, and the value are the
column values (or row values). This can be useful for constructing a DataFrame
with the columns in a particular order without having to pass an explicit list
of columns:

.. ipython:: python

pd.DataFrame.from_items([('A', [1, 2, 3]), ('B', [4, 5, 6])])

If you pass ``orient='index'``, the keys will be the row labels. But in this
case you must also pass the desired column names:

.. ipython:: python

pd.DataFrame.from_items([('A', [1, 2, 3]), ('B', [4, 5, 6])],
orient='index', columns=['one', 'two', 'three'])

Column selection, addition, deletion
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
16 changes: 9 additions & 7 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1255,12 +1255,14 @@ def to_records(self, index=True, convert_datetime64=True):

@classmethod
def from_items(cls, items, columns=None, orient='columns'):
"""
"""Construct a dataframe from a list of tuples

.. deprecated:: 0.23.0
from_items is deprecated and will be removed in a
future version. Use :meth:`DataFrame.from_dict(dict())`
instead. :meth:`DataFrame.from_dict(OrderedDict(...))` may be used
to preserve the key order.
`from_items` is deprecated and will be removed in a future version.
Use :meth:`DataFrame.from_dict(dict(items)) <DataFrame.from_dict>`
instead.
:meth:`DataFrame.from_dict(OrderedDict(items)) <DataFrame.from_dict>`
may be used to preserve the key order.

Convert (key, value) pairs to DataFrame. The keys will be the axis
index (usually the columns, but depends on the specified
Expand All @@ -1284,8 +1286,8 @@ def from_items(cls, items, columns=None, orient='columns'):
"""

warnings.warn("from_items is deprecated. Please use "
"DataFrame.from_dict(dict()) instead. "
"DataFrame.from_dict(OrderedDict()) may be used to "
"DataFrame.from_dict(dict(items), ...) instead. "
"DataFrame.from_dict(OrderedDict(items)) may be used to "
"preserve the key order.",
FutureWarning, stacklevel=2)

Expand Down