8000 DOC: Improved the docstring of Series.str.findall by jcontesti · Pull Request #2 · python-sprints/pandas · GitHub
[go: up one dir, main page]

Skip to content

DOC: Improved the docstring of Series.str.findall #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
96b8bb1
ENH: Implement DataFrame.astype('category') (#18099)
jschendel Mar 1, 2018
4a27697
Cythonized GroupBy any (#19722)
WillAyd Mar 1, 2018
52559f5
ENH: Allow Timestamp to accept Nanosecond argument (#19889)
mroeschke Mar 1, 2018
c8859b5
DOC: script to build single docstring page (#19840)
jorisvandenbossche Mar 1, 2018
3b4eb8d
CLN: remove redundant clean_fill_method calls (#19947)
jorisvandenbossche Mar 1, 2018
9958ce6
BUG: Preserve column metadata with DataFrame.astype (#19948)
jschendel Mar 1, 2018
c5a1ef1
DOC: remove empty attribute/method lists from class docstrings html p…
jorisvandenbossche Mar 1, 2018
9242248
BUG: DataFrame.diff(axis=0) with DatetimeTZ data (#19773)
mroeschke Mar 1, 2018
87fefe2
dispatch Series[datetime64] comparison ops to DatetimeIndex (#19800)
jbrockmendel Mar 1, 2018
d44a6ec
Making to_datetime('today') and Timestamp('today') consistent (#19937)
shangyian Mar 1, 2018
072545d
ENH: Add option to disable MathJax (#19824). (#19856)
davidchall Mar 1, 2018
5f271eb
BUG: Adding skipna as an option to groupby cumsum and cumprod (#19914)
shangyian Mar 1, 2018
d615f86
DOC: Adding script to validate docstrings, and generate list of all f…
datapythonista Mar 2, 2018
e6c7dea
ENH: Let initialisation from dicts use insertion order for python >= …
topper-123 Mar 2, 2018
b167483
DOC: update install.rst to include ActivePython distribution (#19908)
Dr-G Mar 2, 2018
a7a7f8c
DOC: clarify version of ActivePython that includes pandas (#19964)
jorisvandenbossche Mar 2, 2018
fe09b66
First try of my docstring
jcontesti Mar 2, 2018
a227404
DOC: Improved the docstring of Series.str.findall
jcontesti Mar 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
BUG: Preserve column metadata with DataFrame.astype (pandas-dev#19948)
  • Loading branch information
jschendel authored and jreback committed Mar 1, 2018
commit 9958ce68a19477721d2ba53bde2b17bb52ebebaa
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.23.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,7 @@ Reshaping
- Bug in :func:`qcut` where datetime and timedelta data with ``NaT`` present raised a ``ValueError`` (:issue:`19768`)
- Bug in :func:`DataFrame.iterrows`, which would infers strings not compliant to `ISO8601 <https://en.wikipedia.org/wiki/ISO_8601>`_ to datetimes (:issue:`19671`)
- Bug in :class:`Series` constructor with ``Categorical`` where a ```ValueError`` is not raised when an index of different length is given (:issue:`19342`)
- Bug in :meth:`DataFrame.astype` where column metadata is lost when converting to categorical or a dictionary of dtypes (:issue:`19920`)

Other
^^^^^
Expand Down
16 changes: 10 additions & 6 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4436,17 +4436,21 @@ def astype(self, dtype, copy=True, errors='raise', **kwargs):
results.append(col.astype(dtype[col_name], copy=copy))
else:
results.append(results.append(col.copy() if copy else col))
return pd.concat(results, axis=1, copy=False)

elif is_categorical_dtype(dtype) and self.ndim > 1:
# GH 18099: columnwise conversion to categorical
results = (self[col].astype(dtype, copy=copy) for col in self)
return pd.concat(results, axis=1, copy=False)

# else, only a single dtype is given
new_data = self._data.astype(dtype=dtype, copy=copy, errors=errors,
**kwargs)
return self._constructor(new_data).__finalize__(self)
else:
# else, only a single dtype is given
new_data = self._data.astype(dtype=dtype, copy=copy, errors=errors,
**kwargs)
return self._constructor(new_data).__finalize__(self)

# GH 19920: retain column metadata after concat
result = pd.concat(results, axis=1, copy=False)
result.columns = self.columns
return result

def copy(self, deep=True):
"""
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/frame/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,15 @@ def test_astype_categoricaldtype_class_raises(self, cls):
with tm.assert_raises_regex(TypeError, xpr):
df['A'].astype(cls)

@pytest.mark.parametrize('dtype', [
{100: 'float64', 200: 'uint64'}, 'category', 'float64'])
def test_astype_column_metadata(self, dtype):
# GH 19920
columns = pd.UInt64Index([100, 200, 300], name='foo')
df = DataFrame(np.arange(15).reshape(5, 3), columns=columns)
df = df.astype(dtype)
tm.assert_index_equal(df.columns, columns)

@pytest.mark.parametrize("dtype", ["M8", "m8"])
@pytest.mark.parametrize("unit", ['ns', 'us', 'ms', 's', 'h', 'm', 'D'])
def test_astype_from_datetimelike_to_objectt(self, dtype, unit):
Expand Down
0