Skip to content

Commit

Permalink
Merge branch 'main' into ipython
Browse files Browse the repository at this point in the history
  • Loading branch information
saldanhad authored Oct 1, 2024
2 parents 0613ae8 + e78ebd3 commit ebfd576
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 7 deletions.
3 changes: 0 additions & 3 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Timedelta.max PR02" \
-i "pandas.Timedelta.min PR02" \
-i "pandas.Timedelta.resolution PR02" \
-i "pandas.TimedeltaIndex.to_pytimedelta RT03,SA01" \
-i "pandas.Timestamp.max PR02" \
-i "pandas.Timestamp.min PR02" \
-i "pandas.Timestamp.nanosecond GL08" \
Expand Down Expand Up @@ -160,7 +159,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.errors.CSSWarning SA01" \
-i "pandas.errors.CategoricalConversionWarning SA01" \
-i "pandas.errors.ChainedAssignmentError SA01" \
-i "pandas.errors.ClosedFileError SA01" \
-i "pandas.errors.DataError SA01" \
-i "pandas.errors.DuplicateLabelError SA01" \
-i "pandas.errors.IntCastingNaNError SA01" \
Expand All @@ -170,7 +168,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.errors.NumExprClobberingError SA01" \
-i "pandas.errors.NumbaUtilError SA01" \
-i "pandas.errors.OptionError SA01" \
-i "pandas.errors.OutOfBoundsDatetime SA01" \
-i "pandas.errors.OutOfBoundsTimedelta SA01" \
-i "pandas.errors.PerformanceWarning SA01" \
-i "pandas.errors.PossibleDataLossError SA01" \
Expand Down
2 changes: 1 addition & 1 deletion doc/source/user_guide/10min.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ See the indexing documentation :ref:`Indexing and Selecting Data <indexing>` and
Getitem (``[]``)
~~~~~~~~~~~~~~~~

For a :class:`DataFrame`, passing a single label selects a columns and
For a :class:`DataFrame`, passing a single label selects a column and
yields a :class:`Series` equivalent to ``df.A``:

.. ipython:: python
Expand Down
5 changes: 3 additions & 2 deletions doc/source/user_guide/dsintro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ index will be pulled out.

**From scalar value**

If ``data`` is a scalar value, an index must be
provided. The value will be repeated to match the length of **index**.
If ``data`` is a scalar value, the value will be repeated to match
the length of **index**. If the **index** is not provided, it defaults
to ``RangeIndex(1)``.

.. ipython:: python
Expand Down
4 changes: 3 additions & 1 deletion pandas/_libs/src/vendored/ujson/python/JSONtoObj.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ Numeric decoder derived from TCL library

// Licence at LICENSES/ULTRAJSON_LICENSE

#include "pandas/vendored/ujson/lib/ultrajson.h"
// clang-format off
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "pandas/vendored/ujson/lib/ultrajson.h"
// clang-format on

static int Object_objectAddKey(void *Py_UNUSED(prv), JSOBJ obj, JSOBJ name,
JSOBJ value) {
Expand Down
2 changes: 2 additions & 0 deletions pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ class NaTType(_NaT):
--------
to_timedelta : Convert argument to timedelta.
Timedelta : Represents a duration, the difference between two dates or times.
Timedelta.seconds : Returns the seconds component of the timedelta.
Timedelta.microseconds : Returns the microseconds component of the timedelta.
Examples
--------
Expand Down
9 changes: 9 additions & 0 deletions pandas/_libs/tslibs/np_datetime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,15 @@ class OutOfBoundsDatetime(ValueError):
"""
Raised when the datetime is outside the range that can be represented.
This error occurs when attempting to convert or parse a datetime value
that exceeds the bounds supported by pandas' internal datetime
representation.
See Also
--------
to_datetime : Convert argument to datetime.
Timestamp : Pandas replacement for python ``datetime.datetime`` object.
Examples
--------
>>> pd.to_datetime("08335394550")
Expand Down
3 changes: 3 additions & 0 deletions pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,8 @@ cdef class _Timedelta(timedelta):
--------
to_timedelta : Convert argument to timedelta.
Timedelta : Represents a duration, the difference between two dates or times.
Timedelta.seconds : Returns the seconds component of the timedelta.
Timedelta.microseconds : Returns the microseconds component of the timedelta.

Examples
--------
Expand Down Expand Up @@ -1493,6 +1495,7 @@ cdef class _Timedelta(timedelta):
See Also
--------
Timedelta.asm8 : Return a numpy timedelta64 array scalar view.
numpy.ndarray.view : Returns a view of an array with the same data.
Timedelta.to_numpy : Converts the Timedelta to a NumPy timedelta64.
Timedelta.total_seconds : Returns the total duration of the Timedelta
Expand Down
21 changes: 21 additions & 0 deletions pandas/core/arrays/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,19 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]:
Returns
-------
numpy.ndarray
A NumPy ``timedelta64`` object representing the same duration as the
original pandas ``Timedelta`` object. The precision of the resulting
object is in nanoseconds, which is the default
time resolution used by pandas for ``Timedelta`` objects, ensuring
high precision for time-based calculations.
See Also
--------
to_timedelta : Convert argument to timedelta format.
Timedelta : Represents a duration between two dates or times.
DatetimeIndex: Index of datetime64 data.
Timedelta.components : Return a components namedtuple-like
of a single timedelta.
Examples
--------
Expand All @@ -800,6 +813,14 @@ def to_pytimedelta(self) -> npt.NDArray[np.object_]:
>>> tdelta_idx.to_pytimedelta()
array([datetime.timedelta(days=1), datetime.timedelta(days=2),
datetime.timedelta(days=3)], dtype=object)
>>> tidx = pd.TimedeltaIndex(data=["1 days 02:30:45", "3 days 04:15:10"])
>>> tidx
TimedeltaIndex(['1 days 02:30:45', '3 days 04:15:10'],
dtype='timedelta64[ns]', freq=None)
>>> tidx.to_pytimedelta()
array([datetime.timedelta(days=1, seconds=9045),
datetime.timedelta(days=3, seconds=15310)], dtype=object)
"""
return ints_to_pytimedelta(self._ndarray)

Expand Down
10 changes: 10 additions & 0 deletions pandas/errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,16 @@ class ClosedFileError(Exception):
"""
Exception is raised when trying to perform an operation on a closed HDFStore file.
``ClosedFileError`` is specific to operations on ``HDFStore`` objects. Once an
HDFStore is closed, its resources are no longer available, and any further attempt
to access data or perform file operations will raise this exception.
See Also
--------
HDFStore.close : Closes the PyTables file handle.
HDFStore.open : Opens the file in the specified mode.
HDFStore.is_open : Returns a boolean indicating whether the file is open.
Examples
--------
>>> store = pd.HDFStore("my-store", "a") # doctest: +SKIP
Expand Down

0 comments on commit ebfd576

Please sign in to comment.