Description
Under #18262 a FutureWarning
was added suggesting that existing code like this:
pd.DataFrame.from_items(x)
Should be changed to this:
import collections
pd.DataFrame.from_dict(collections.OrderedDict(x))
The fact that from_items()
appeared only 6 times (now 8 times) in a Stack Overflow search was used as partial justification for removing it. But if you search on GitHub, pd.DataFrame.from_items()
appears more than 15,000 times in Python--almost half as many as from_records()
!
We should celebrate the fact that this function doesn't cause enough confusion to appear often on Stack Overflow. But it does occur (a lot!) in real code, and deprecating it is a mistake.
If constructing a temporary OrderedDict
around items is the best way to construct a DataFrame, Pandas should implement that as a short function called DataFrame.from_items()
, rather than asking thousands of people to busy themselves to accommodate this unnecessary API change.
I recommend removing the FutureWarning, and retaining this widely-used, longstanding function.
For reference, the FutureWarning
starts in 0.23 and looks like this:
FutureWarning: from_items is deprecated. Please use DataFrame.from_dict(dict(items), ...) instead. DataFrame.from_dict(OrderedDict(items)) may be used to preserve the key order.