10000 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: DataFrame.diff(axis=0) with DatetimeTZ data (pandas-dev#19773)
  • Loading branch information
mroeschke authored and jreback committed Mar 1, 2018
commit 9242248068e3f9ba18bef2b83005c3a80b873835
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 @@ -833,6 +833,7 @@ Timezones
- Bug in the :class:`DataFrame` constructor, where tz-aware Datetimeindex and a given column name will result in an empty ``DataFrame`` (:issue:`19157`)
- Bug in :func:`Timestamp.tz_localize` where localizing a timestamp near the minimum or maximum valid values could overflow and return a timestamp with an incorrect nanosecond value (:issue:`12677`)
- Bug when iterating over :class:`DatetimeIndex` that was localized with fixed timezone offset that rounded nanosecond precision to microseconds (:issue:`19603`)
- Bug in :func:`DataFrame.diff` that raised an ``IndexError`` with tz-aware values (:issue:`18578`)

Offsets
^^^^^^^
Expand Down
29 changes: 29 additions & 0 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2905,6 +2905,35 @@ def shift(self, periods, axis=0, mgr=None):
return [self.make_block_same_class(new_values,
placement=self.mgr_locs)]

def diff(self, n, axis=0, mgr=None):
"""1st discrete difference

Parameters
----------
n : int, number of periods to diff
axis : int, axis to diff upon. default 0
mgr : default None

Return
------
A list with a new TimeDeltaBlock.

Note
----
The arguments here are mimicking shift so they are called correctly
by apply.
"""
if axis == 0:
# Cannot currently calculate diff across multiple blocks since this
# function is invoked via apply
raise NotImplementedError
new_values = (self.values - self.shift(n, axis=axis)[0].values).asi8

# Reshape the new_values like how algos.diff does for timedelta data
new_values = new_values.reshape(1, len(new_values))
new_values = new_values.astype('timedelta64[ns]')
return [TimeDeltaBlock(new_values, placement=self.mgr_locs.indexer)]

def concat_same_type(self, to_concat, placement=None):
"""
Concatenate list of single blocks of the same type.
Expand Down
26 changes: 26 additions & 0 deletions pandas/tests/frame/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,32 @@ def test_diff(self):
1), 'z': pd.Series(1)}).astype('float64')
assert_frame_equal(result, expected)

@pytest.mark.parametrize('tz', [None, 'UTC'])
def test_diff_datetime_axis0(self, tz):
# GH 18578
df = DataFrame({0: date_range('2010', freq='D', periods=2, tz=tz),
1: date_range('2010', freq='D', periods=2, tz=tz)})

result = df.diff(axis=0)
expected = DataFrame({0: pd.TimedeltaIndex(['NaT', '1 days']),
1: pd.TimedeltaIndex(['NaT', '1 days'])})
assert_frame_equal(result, expected)

@pytest.mark.parametrize('tz', [None, 'UTC'])
def test_diff_datetime_axis1(self, tz):
# GH 18578
df = DataFrame({0: date_range('2010', freq='D', periods=2, tz=tz),
1: date_range('2010', freq='D', periods=2, tz=tz)})
if tz is None:
result = df.diff(axis=1)
expected = DataFrame({0: pd.TimedeltaIndex(['NaT', 'NaT']),
1: pd.TimedeltaIndex(['0 days',
'0 days'])})
assert_frame_equal(result, expected)
else:
with pytest.raises(NotImplementedError):
result = df.diff(axis=1)

def test_diff_timedelta(self):
# GH 4533
df = DataFrame(dict(time=[Timestamp('20130101 9:01'),
Expand Down
0