|
25 | 25 | from pandas.core.daterange import DateRange
|
26 | 26 | from pandas.core.generic import AxisProperty, NDFrame
|
27 | 27 | from pandas.core.index import Index, MultiIndex, NULL_INDEX
|
28 |
| -from pandas.core.indexing import _DataFrameIndexer, _maybe_droplevels |
| 28 | +from pandas.core.indexing import _NDFrameIndexer, _maybe_droplevels |
29 | 29 | from pandas.core.internals import BlockManager, make_block, form_blocks
|
30 | 30 | from pandas.core.series import Series, _is_bool_indexer
|
31 | 31 | from pandas.util.decorators import deprecate
|
@@ -244,7 +244,7 @@ def _constructor(self):
|
244 | 244 | @property
|
245 | 245 | def ix(self):
|
246 | 246 | if self._ix is None:
|
247 |
| - self._ix = _DataFrameIndexer(self) |
| 247 | + self._ix = _NDFrameIndexer(self) |
248 | 248 |
|
249 | 249 | return self._ix
|
250 | 250 |
|
@@ -948,19 +948,30 @@ def pop(self, item):
|
948 | 948 | def _series(self):
|
949 | 949 | return self._data.get_series_dict()
|
950 | 950 |
|
951 |
| - def xs(self, key, copy=True): |
| 951 | + def xs(self, key, axis=0, copy=True): |
952 | 952 | """
|
953 |
| - Returns a row (cross-section) from the DataFrame as a Series object |
| 953 | + Returns a cross-section (row or column) from the DataFrame as a Series |
| 954 | + object. Defaults to returning a row (axis 0) |
954 | 955 |
|
955 | 956 | Parameters
|
956 | 957 | ----------
|
957 | 958 | key : object
|
958 | 959 | Some label contained in the index, or partially in a MultiIndex
|
| 960 | + axis : int, default 0 |
| 961 | + Axis to retrieve cross-section on |
| 962 | + copy : boolean, default True |
| 963 | + Whether to make a copy of the data |
959 | 964 |
|
960 | 965 | Returns
|
961 | 966 | -------
|
962 | 967 | xs : Series
|
963 | 968 | """
|
| 969 | + if axis == 1: |
| 970 | + data = self[key] |
| 971 | + if copy: |
| 972 | + data = data.copy() |
| 973 | + return data |
| 974 | + |
964 | 975 | self._consolidate_inplace()
|
965 | 976 | new_data = self._data.xs(key, axis=1, copy=copy)
|
966 | 977 | if new_data.ndim == 1:
|
|
0 commit comments