Skip to content

Sync Fork from Upstream Repo #78

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

Merged
merged 11 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions doc/source/whatsnew/v1.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ Numeric
Conversion
^^^^^^^^^^
- Bug in :class:`Series` construction from NumPy array with big-endian ``datetime64`` dtype (:issue:`29684`)
-
- Bug in :class:`Timedelta` construction with large nanoseconds keyword value (:issue:`34202`)
-

Strings
Expand Down Expand Up @@ -327,6 +327,7 @@ Reshaping
- Bug in :func:`crosstab` when inputs are two Series and have tuple names, the output will keep dummy MultiIndex as columns. (:issue:`18321`)
- :meth:`DataFrame.pivot` can now take lists for ``index`` and ``columns`` arguments (:issue:`21425`)
- Bug in :func:`concat` where the resulting indices are not copied when ``copy=True`` (:issue:`29879`)
- :meth:`Series.append` will now raise a ``TypeError`` when passed a DataFrame or a sequence containing Dataframe (:issue:`31413`)
- :meth:`DataFrame.replace` and :meth:`Series.replace` will raise a ``TypeError`` if ``to_replace`` is not an expected type. Previously the ``replace`` would fail silently (:issue:`18634`)


Expand All @@ -349,7 +350,6 @@ Other
instead of ``TypeError: Can only append a Series if ignore_index=True or if the Series has a name`` (:issue:`30871`)
- Set operations on an object-dtype :class:`Index` now always return object-dtype results (:issue:`31401`)
- Bug in :meth:`AbstractHolidayCalendar.holidays` when no rules were defined (:issue:`31415`)
-

.. ---------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ class Timedelta(_Timedelta):

kwargs = {key: _to_py_int_float(kwargs[key]) for key in kwargs}

nano = np.timedelta64(kwargs.pop('nanoseconds', 0), 'ns')
nano = convert_to_timedelta64(kwargs.pop('nanoseconds', 0), 'ns')
try:
value = nano + convert_to_timedelta64(timedelta(**kwargs),
'ns')
Expand Down
16 changes: 8 additions & 8 deletions pandas/_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,11 +706,11 @@ def _get_ilevel_values(index, level):
if isinstance(left, pd.PeriodIndex) or isinstance(right, pd.PeriodIndex):
assert_attr_equal("freq", left, right, obj=obj)
if isinstance(left, pd.IntervalIndex) or isinstance(right, pd.IntervalIndex):
assert_interval_array_equal(left.values, right.values)
assert_interval_array_equal(left._values, right._values)

if check_categorical:
if is_categorical_dtype(left) or is_categorical_dtype(right):
assert_categorical_equal(left.values, right.values, obj=f"{obj} category")
assert_categorical_equal(left._values, right._values, obj=f"{obj} category")


def assert_class_equal(left, right, exact: Union[bool, str] = True, obj="Input"):
Expand Down Expand Up @@ -883,7 +883,7 @@ def assert_interval_array_equal(left, right, exact="equiv", obj="IntervalArray")
def assert_period_array_equal(left, right, obj="PeriodArray"):
_check_isinstance(left, right, PeriodArray)

assert_numpy_array_equal(left._data, right._data, obj=f"{obj}.values")
assert_numpy_array_equal(left._data, right._data, obj=f"{obj}._data")
assert_attr_equal("freq", left, right, obj=obj)


Expand Down Expand Up @@ -1170,10 +1170,10 @@ def assert_series_equal(

# datetimelike may have different objects (e.g. datetime.datetime
# vs Timestamp) but will compare equal
if not Index(left.values).equals(Index(right.values)):
if not Index(left._values).equals(Index(right._values)):
msg = (
f"[datetimelike_compat=True] {left.values} "
f"is not equal to {right.values}."
f"[datetimelike_compat=True] {left._values} "
f"is not equal to {right._values}."
)
raise AssertionError(msg)
else:
Expand Down Expand Up @@ -1212,8 +1212,8 @@ def assert_series_equal(
if check_categorical:
if is_categorical_dtype(left) or is_categorical_dtype(right):
assert_categorical_equal(
left.values,
right.values,
left._values,
right._values,
obj=f"{obj} category",
check_category_order=check_category_order,
)
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,9 +1181,11 @@ def try_timedelta(v):
from pandas import to_timedelta

try:
return to_timedelta(v)._ndarray_values.reshape(shape)
td_values = to_timedelta(v)
except ValueError:
return v.reshape(shape)
else:
return np.asarray(td_values).reshape(shape)

inferred_type = lib.infer_datetimelike_array(ensure_object(v))

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -4580,7 +4580,7 @@ def drop_duplicates(
duplicated = self.duplicated(subset, keep=keep)

if inplace:
(inds,) = (-duplicated)._ndarray_values.nonzero()
(inds,) = np.asarray(-duplicated).nonzero()
new_data = self._data.take(inds)

if ignore_index:
Expand Down
Loading