Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into pivot
Browse files Browse the repository at this point in the history
* upstream/master:
  BUG: Fix passing of numeric_only argument for categorical reduce (pandas-dev#25304)
  ENH: Support times with timezones in at_time (pandas-dev#25280)
  COMPAT: alias .to_numpy() for timestamp and timedelta scalars (pandas-dev#25142)
  DOC/CLN: Fix various docstring errors (pandas-dev#25295)
  Bug: OverflowError in resample.agg with tz data (pandas-dev#25297)
  Fixes Formatting Exception (pandas-dev#25088)
  BUG: groupby.transform retains timezone information (pandas-dev#25264)
  Doc: corrects spelling in generic.py (pandas-dev#25333)
  Fix typos in docs (pandas-dev#25305)
  • Loading branch information
thoo committed Feb 16, 2019
2 parents ad4a761 + 29008f5 commit 38d545c
Show file tree
Hide file tree
Showing 31 changed files with 456 additions and 244 deletions.
2 changes: 2 additions & 0 deletions doc/source/reference/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Methods
Timestamp.timetuple
Timestamp.timetz
Timestamp.to_datetime64
Timestamp.to_numpy
Timestamp.to_julian_date
Timestamp.to_period
Timestamp.to_pydatetime
Expand Down Expand Up @@ -191,6 +192,7 @@ Methods
Timedelta.round
Timedelta.to_pytimedelta
Timedelta.to_timedelta64
Timedelta.to_numpy
Timedelta.total_seconds

A collection of timedeltas may be stored in a :class:`TimedeltaArray`.
Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide/groupby.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ arbitrary function, for example:
df.groupby(['Store', 'Product']).pipe(mean)
where ``mean`` takes a GroupBy object and finds the mean of the Revenue and Quantity
columns repectively for each Store-Product combination. The ``mean`` function can
columns respectively for each Store-Product combination. The ``mean`` function can
be any function that takes in a GroupBy object; the ``.pipe`` will pass the GroupBy
object as a parameter into the function you specify.

Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.10.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ Updated PyTables Support
df1.get_dtype_counts()
- performance improvements on table writing
- support for arbitrarly indexed dimensions
- support for arbitrarily indexed dimensions
- ``SparseSeries`` now has a ``density`` property (:issue:`2384`)
- enable ``Series.str.strip/lstrip/rstrip`` methods to take an input argument
to strip arbitrary characters (:issue:`2411`)
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.16.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ groupby operations on the index will preserve the index nature as well
reindexing operations, will return a resulting index based on the type of the passed
indexer, meaning that passing a list will return a plain-old-``Index``; indexing with
a ``Categorical`` will return a ``CategoricalIndex``, indexed according to the categories
of the PASSED ``Categorical`` dtype. This allows one to arbitrarly index these even with
of the PASSED ``Categorical`` dtype. This allows one to arbitrarily index these even with
values NOT in the categories, similarly to how you can reindex ANY pandas index.

.. code-block:: ipython
Expand Down
4 changes: 3 additions & 1 deletion doc/source/whatsnew/v0.24.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Fixed Regressions
- Fixed regression in :meth:`DataFrame.apply` causing ``RecursionError`` when ``dict``-like classes were passed as argument. (:issue:`25196`)

- Fixed regression in :meth:`DataFrame.duplicated()`, where empty dataframe was not returning a boolean dtyped Series. (:issue:`25184`)
- Fixed regression in :meth:`Series.min` and :meth:`Series.max` where ``numeric_only=True`` was ignored when the ``Series`` contained ```Categorical`` data (:issue:`25299`)

.. _whatsnew_0242.enhancements:

Expand Down Expand Up @@ -53,6 +54,7 @@ Bug Fixes

**I/O**

- Better handling of terminal printing when the terminal dimensions are not known (:issue:`25080`);
- Bug in reading a HDF5 table-format ``DataFrame`` created in Python 2, in Python 3 (:issue:`24925`)
- Bug in reading a JSON with ``orient='table'`` generated by :meth:`DataFrame.to_json` with ``index=False`` (:issue:`25170`)
- Bug where float indexes could have misaligned values when printing (:issue:`25061`)
Expand All @@ -78,7 +80,7 @@ Bug Fixes

**Reshaping**

-
- Bug in :meth:`pandas.core.groupby.GroupBy.transform` where applying a function to a timezone aware column would return a timezone naive result (:issue:`24198`)
- Bug in :func:`DataFrame.join` when joining on a timezone aware :class:`DatetimeIndex` (:issue:`23931`)
-

Expand Down
7 changes: 4 additions & 3 deletions doc/source/whatsnew/v0.25.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Other Enhancements
^^^^^^^^^^^^^^^^^^

- :meth:`Timestamp.replace` now supports the ``fold`` argument to disambiguate DST transition times (:issue:`25017`)
- :meth:`DataFrame.pivot` now supports multiple column indexes (:issue:`21425`)
-
- :meth:`DataFrame.at_time` and :meth:`Series.at_time` now support :meth:`datetime.time` objects with timezones (:issue:`24043`)
- :meth:`DataFrame.pivot` now supports multiple column indexes by accepting a list of columns (:issue:`21425`)

.. _whatsnew_0250.api_breaking:

Expand All @@ -34,6 +34,7 @@ Other API Changes
^^^^^^^^^^^^^^^^^

- :class:`DatetimeTZDtype` will now standardize pytz timezones to a common timezone instance (:issue:`24713`)
- ``Timestamp`` and ``Timedelta`` scalars now implement the :meth:`to_numpy` method as aliases to :meth:`Timestamp.to_datetime64` and :meth:`Timedelta.to_timedelta64`, respectively. (:issue:`24653`)
-
-

Expand Down Expand Up @@ -172,7 +173,7 @@ Plotting
Groupby/Resample/Rolling
^^^^^^^^^^^^^^^^^^^^^^^^

-
- Bug in :meth:`pandas.core.resample.Resampler.agg` with a timezone aware index where ``OverflowError`` would raise when passing a list of functions (:issue:`22660`)
-
-

Expand Down
20 changes: 20 additions & 0 deletions pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,26 @@ cdef class _NaT(datetime):
"""
return np.datetime64('NaT', 'ns')

def to_numpy(self, dtype=None, copy=False):
"""
Convert the Timestamp to a NumPy datetime64.
.. versionadded:: 0.25.0
This is an alias method for `Timestamp.to_datetime64()`. The dtype and
copy parameters are available here only for compatibility. Their values
will not affect the return value.
Returns
-------
numpy.datetime64
See Also
--------
DatetimeIndex.to_numpy : Similar method for DatetimeIndex.
"""
return self.to_datetime64()

def __repr__(self):
return 'NaT'

Expand Down
20 changes: 20 additions & 0 deletions pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,26 @@ cdef class _Timedelta(timedelta):
""" Returns a numpy.timedelta64 object with 'ns' precision """
return np.timedelta64(self.value, 'ns')

def to_numpy(self, dtype=None, copy=False):
"""
Convert the Timestamp to a NumPy timedelta64.
.. versionadded:: 0.25.0
This is an alias method for `Timedelta.to_timedelta64()`. The dtype and
copy parameters are available here only for compatibility. Their values
will not affect the return value.
Returns
-------
numpy.timedelta64
See Also
--------
Series.to_numpy : Similar method for Series.
"""
return self.to_timedelta64()

def total_seconds(self):
"""
Total duration of timedelta in seconds (to ns precision)
Expand Down
20 changes: 20 additions & 0 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,26 @@ cdef class _Timestamp(datetime):
"""
return np.datetime64(self.value, 'ns')

def to_numpy(self, dtype=None, copy=False):
"""
Convert the Timestamp to a NumPy datetime64.
.. versionadded:: 0.25.0
This is an alias method for `Timestamp.to_datetime64()`. The dtype and
copy parameters are available here only for compatibility. Their values
will not affect the return value.
Returns
-------
numpy.datetime64
See Also
--------
DatetimeIndex.to_numpy : Similar method for DatetimeIndex.
"""
return self.to_datetime64()

def __add__(self, other):
cdef:
int64_t other_int, nanos
Expand Down
Loading

0 comments on commit 38d545c

Please sign in to comment.