|
76 | 76 | is_iterator,
|
77 | 77 | is_list_like,
|
78 | 78 | is_named_tuple,
|
79 |
| - is_nested_list_like, |
80 | 79 | is_object_dtype,
|
81 | 80 | is_scalar,
|
82 | 81 | is_sequence,
|
@@ -342,8 +341,9 @@ class DataFrame(NDFrame):
|
342 | 341 | --------
|
343 | 342 | DataFrame.from_records : Constructor from tuples, also record arrays.
|
344 | 343 | DataFrame.from_dict : From dicts of Series, arrays, or dicts.
|
345 |
| - DataFrame.from_items : From sequence of (key, value) pairs |
346 |
| - read_csv, pandas.read_table, pandas.read_clipboard. |
| 344 | + read_csv |
| 345 | + read_table |
| 346 | + read_clipboard |
347 | 347 |
|
348 | 348 | Examples
|
349 | 349 | --------
|
@@ -387,9 +387,7 @@ def _constructor(self) -> Type["DataFrame"]:
|
387 | 387 | return DataFrame
|
388 | 388 |
|
389 | 389 | _constructor_sliced = Series # type: Type[Series]
|
390 |
| - _deprecations = NDFrame._deprecations | frozenset( |
391 |
| - ["from_items"] |
392 |
| - ) # type: FrozenSet[str] |
| 390 | + _deprecations = NDFrame._deprecations | frozenset([]) # type: FrozenSet[str] |
393 | 391 | _accessors = set() # type: Set[str]
|
394 | 392 |
|
395 | 393 | @property
|
@@ -1850,103 +1848,6 @@ def to_records(self, index=True, column_dtypes=None, index_dtypes=None):
|
1850 | 1848 |
|
1851 | 1849 | return np.rec.fromarrays(arrays, dtype={"names": names, "formats": formats})
|
1852 | 1850 |
|
1853 |
| - @classmethod |
1854 |
| - def from_items(cls, items, columns=None, orient="columns"): |
1855 |
| - """ |
1856 |
| - Construct a DataFrame from a list of tuples. |
1857 |
| -
|
1858 |
| - .. deprecated:: 0.23.0 |
1859 |
| - `from_items` is deprecated and will be removed in a future version. |
1860 |
| - Use :meth:`DataFrame.from_dict(dict(items)) <DataFrame.from_dict>` |
1861 |
| - instead. |
1862 |
| - :meth:`DataFrame.from_dict(OrderedDict(items)) <DataFrame.from_dict>` |
1863 |
| - may be used to preserve the key order. |
1864 |
| -
|
1865 |
| - Convert (key, value) pairs to DataFrame. The keys will be the axis |
1866 |
| - index (usually the columns, but depends on the specified |
1867 |
| - orientation). The values should be arrays or Series. |
1868 |
| -
|
1869 |
| - Parameters |
1870 |
| - ---------- |
1871 |
| - items : sequence of (key, value) pairs |
1872 |
| - Values should be arrays or Series. |
1873 |
| - columns : sequence of column labels, optional |
1874 |
| - Must be passed if orient='index'. |
1875 |
| - orient : {'columns', 'index'}, default 'columns' |
1876 |
| - The "orientation" of the data. If the keys of the |
1877 |
| - input correspond to column labels, pass 'columns' |
1878 |
| - (default). Otherwise if the keys correspond to the index, |
1879 |
| - pass 'index'. |
1880 |
| -
|
1881 |
| - Returns |
1882 |
| - ------- |
1883 |
| - DataFrame |
1884 |
| - """ |
1885 |
| - |
1886 |
| - warnings.warn( |
1887 |
| - "from_items is deprecated. Please use " |
1888 |
| - "DataFrame.from_dict(dict(items), ...) instead. " |
1889 |
| - "DataFrame.from_dict(OrderedDict(items)) may be used to " |
1890 |
| - "preserve the key order.", |
1891 |
| - FutureWarning, |
1892 |
| - stacklevel=2, |
1893 |
| - ) |
1894 |
| - |
1895 |
| - keys, values = zip(*items) |
1896 |
| - |
1897 |
| - if orient == "columns": |
1898 |
| - if columns is not None: |
1899 |
| - columns = ensure_index(columns) |
1900 |
| - |
1901 |
| - idict = dict(items) |
1902 |
| - if len(idict) < len(items): |
1903 |
| - if not columns.equals(ensure_index(keys)): |
1904 |
| - raise ValueError( |
1905 |
| - "With non-unique item names, passed " |
1906 |
| - "columns must be identical" |
1907 |
| - ) |
1908 |
| - arrays = values |
1909 |
| - else: |
1910 |
| - arrays = [idict[k] for k in columns if k in idict] |
1911 |
| - else: |
1912 |
| - columns = ensure_index(keys) |
1913 |
| - arrays = values |
1914 |
| - |
1915 |
| - # GH 17312 |
1916 |
| - # Provide more informative error msg when scalar values passed |
1917 |
| - try: |
1918 |
| - return cls._from_arrays(arrays, columns, None) |
1919 |
| - |
1920 |
| - except ValueError: |
1921 |
| - if not is_nested_list_like(values): |
1922 |
| - raise ValueError( |
1923 |
| - "The value in each (key, value) pair " |
1924 |
| - "must be an array, Series, or dict" |
1925 |
| - ) |
1926 |
| - |
1927 |
| - elif orient == "index": |
1928 |
| - if columns is None: |
1929 |
| - raise TypeError("Must pass columns with orient='index'") |
1930 |
| - |
1931 |
| - keys = ensure_index(keys) |
1932 |
| - |
1933 |
| - # GH 17312 |
1934 |
| - # Provide more informative error msg when scalar values passed |
1935 |
| - try: |
1936 |
| - arr = np.array(values, dtype=object).T |
1937 |
| - data = [lib.maybe_convert_objects(v) for v in arr] |
1938 |
| - return cls._from_arrays(data, columns, keys) |
1939 |
| - |
1940 |
| - except TypeError: |
1941 |
| - if not is_nested_list_like(values): |
1942 |
| - raise ValueError( |
1943 |
| - "The value in each (key, value) pair " |
1944 |
| - "must be an array, Series, or dict" |
1945 |
| - ) |
1946 |
| - |
1947 |
| - else: # pragma: no cover |
1948 |
| - raise ValueError("'orient' must be either 'columns' or 'index'") |
1949 |
| - |
1950 | 1851 | @classmethod
|
1951 | 1852 | def _from_arrays(cls, arrays, columns, index, dtype=None):
|
1952 | 1853 | mgr = arrays_to_mgr(arrays, columns, index, columns, dtype=dtype)
|
|
0 commit comments