@@ -364,6 +364,19 @@ and returns a DataFrame. It operates like the ``DataFrame`` constructor except
364364for the ``orient `` parameter which is ``'columns' `` by default, but which can be
365365set to ``'index' `` in order to use the dict keys as row labels.
366366
367+
368+ .. ipython :: python
369+
370+ pd.DataFrame.from_dict(dict ([(' A' , [1 , 2 , 3 ]), (' B' , [4 , 5 , 6 ])]))
371+
372+ If you pass ``orient='index' ``, the keys will be the row labels. In this
373+ case, you can also pass the desired column names:
374+
375+ .. ipython :: python
376+
377+ pd.DataFrame.from_dict(dict ([(' A' , [1 , 2 , 3 ]), (' B' , [4 , 5 , 6 ])]),
378+ orient = ' index' , columns = [' one' , ' two' , ' three' ])
379+
367380 .. _basics.dataframe.from_records :
368381
369382**DataFrame.from_records **
@@ -378,28 +391,6 @@ dtype. For example:
378391 data
379392 pd.DataFrame.from_records(data, index = ' C' )
380393
381- .. _basics.dataframe.from_items :
382-
383- **DataFrame.from_items **
384-
385- ``DataFrame.from_items `` works analogously to the form of the ``dict ``
386- constructor that takes a sequence of ``(key, value) `` pairs, where the keys are
387- column (or row, in the case of ``orient='index' ``) names, and the value are the
388- column values (or row values). This can be useful for constructing a DataFrame
389- with the columns in a particular order without having to pass an explicit list
390- of columns:
391-
392- .. ipython :: python
393-
394- pd.DataFrame.from_items([(' A' , [1 , 2 , 3 ]), (' B' , [4 , 5 , 6 ])])
395-
396- If you pass ``orient='index' ``, the keys will be the row labels. But in this
397- case you must also pass the desired column names:
398-
399- .. ipython :: python
400-
401- pd.DataFrame.from_items([(' A' , [1 , 2 , 3 ]), (' B' , [4 , 5 , 6 ])],
402- orient = ' index' , columns = [' one' , ' two' , ' three' ])
403394
404395 Column selection, addition, deletion
405396~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0 commit comments