Skip to content

Commit 01619b5

Browse files
committed
Move to 1.0
1 parent 87a8ce6 commit 01619b5

File tree

3 files changed

+33
-34
lines changed

3 files changed

+33
-34
lines changed

doc/source/whatsnew/v0.25.0.rst

-30
Original file line numberDiff line numberDiff line change
@@ -182,36 +182,6 @@ The repr now looks like this:
182182
json_normalize(data, max_level=1)
183183
184184
185-
.. _whatsnew_0250.enhancements.loc_regex:
186-
187-
Selection using regular expressions
188-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
189-
190-
It is now possible to call :attr:`~DataFrame.loc` with parameter ``regex=True`` to select by
191-
row/columns axis labels that match a regular expression pattern.
192-
193-
.. ipython:: python
194-
195-
df = pd.DataFrame(1, index=["A", "AB", "BC"], columns=["BC", "AB", "A"])
196-
df
197-
198-
df.loc(regex=True)["B", "B"]
199-
df.loc(axis=1, regex=True)["B"]
200-
201-
The regex matching will only work when looking up single strings, not list of strings etc.
202-
203-
.. ipython:: python
204-
205-
df.loc(regex=True)[["A"], "A"]
206-
207-
Is is currently not possible to set values for a given regular expression.
208-
209-
.. ipython:: python
210-
:okexcept:
211-
212-
df.loc(regex=True)["B", "B"] = [[1, 2], [3, 4]]
213-
214-
215185
.. _whatsnew_0250.enhancements.explode:
216186

217187
Series.explode to split list-like values to rows

doc/source/whatsnew/v1.0.0.rst

+30
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,36 @@ including other versions of pandas.
2121
Enhancements
2222
~~~~~~~~~~~~
2323

24+
.. _whatsnew_0250.enhancements.loc_regex:
25+
26+
Selection using regular expressions
27+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28+
29+
It is now possible to call :attr:`~DataFrame.loc` with parameter ``regex=True`` to select by
30+
row/columns axis labels that match a regular expression pattern.
31+
32+
.. ipython:: python
33+
34+
df = pd.DataFrame(1, index=["A", "AB", "BC"], columns=["BC", "AB", "A"])
35+
df
36+
37+
df.loc(regex=True)["B", "B"]
38+
df.loc(axis=1, regex=True)["B"]
39+
40+
The regex matching will only work when looking up single strings, not list of strings etc.
41+
42+
.. ipython:: python
43+
44+
df.loc(regex=True)[["A"], "A"]
45+
46+
Is is currently not possible to set values for a given regular expression.
47+
48+
.. ipython:: python
49+
:okexcept:
50+
51+
df.loc(regex=True)["B", "B"] = [[1, 2], [3, 4]]
52+
53+
2454
.. _whatsnew_1000.enhancements.other:
2555

2656
-

pandas/core/indexing.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -941,11 +941,11 @@ def _getitem_lowerdim(self, tup: Tuple):
941941
if com.is_null_slice(new_key):
942942
return section
943943

944-
return self._getitem_lower_dim(section, new_key)
944+
return self._getitem_lower_section(section, new_key)
945945

946946
raise IndexingError("not applicable")
947947

948-
def _getitem_lower_dim(self, section, key):
948+
def _getitem_lower_section(self, section, key):
949949
# This is an elided recursive call to iloc/loc/etc'
950950
return getattr(section, self.name)[key]
951951

@@ -1871,14 +1871,13 @@ def _getitem_axis(self, key, axis: int):
18711871
return self.obj.iloc[tuple(indexer)]
18721872

18731873
elif self.regex and isinstance(key, (str, bytes)):
1874-
print(key, axis)
18751874
return self._getitem_regex(key, axis=axis)
18761875

18771876
# fall thru to straight lookup
18781877
self._validate_key(key, axis)
18791878
return self._get_label(key, axis=axis)
18801879

1881-
def _getitem_lower_dim(self, section, key):
1880+
def _getitem_lower_section(self, section, key):
18821881
return getattr(section, self.name)(regex=self.regex)[key]
18831882

18841883
def __setitem__(self, key, value):

0 commit comments

Comments
 (0)