Skip to content

Commit bb52809

Browse files
authored
Merge pull request #7 from pandas-dev/master
Updation of fork
2 parents 4bbdc6a + 1a576eb commit bb52809

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

pandas/core/aggregation.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@
1010
Callable,
1111
DefaultDict,
1212
Dict,
13+
Iterable,
1314
List,
1415
Optional,
1516
Sequence,
1617
Tuple,
1718
Union,
1819
)
1920

20-
from pandas._typing import AggFuncType, Label
21+
from pandas._typing import AggFuncType, FrameOrSeries, Label
2122

2223
from pandas.core.dtypes.common import is_dict_like, is_list_like
2324

2425
from pandas.core.base import SpecificationError
2526
import pandas.core.common as com
2627
from pandas.core.indexes.api import Index
27-
from pandas.core.series import FrameOrSeriesUnion, Series
28+
from pandas.core.series import Series
2829

2930

3031
def reconstruct_func(
@@ -276,12 +277,13 @@ def maybe_mangle_lambdas(agg_spec: Any) -> Any:
276277

277278

278279
def relabel_result(
279-
result: FrameOrSeriesUnion,
280+
result: FrameOrSeries,
280281
func: Dict[str, List[Union[Callable, str]]],
281-
columns: Tuple,
282-
order: List[int],
282+
columns: Iterable[Label],
283+
order: Iterable[int],
283284
) -> Dict[Label, Series]:
284-
"""Internal function to reorder result if relabelling is True for
285+
"""
286+
Internal function to reorder result if relabelling is True for
285287
dataframe.agg, and return the reordered result in dict.
286288
287289
Parameters:

pandas/core/frame.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7415,6 +7415,12 @@ def aggregate(self, func=None, axis=0, *args, **kwargs):
74157415
if relabeling:
74167416
# This is to keep the order to columns occurrence unchanged, and also
74177417
# keep the order of new columns occurrence unchanged
7418+
7419+
# For the return values of reconstruct_func, if relabeling is
7420+
# False, columns and order will be None.
7421+
assert columns is not None
7422+
assert order is not None
7423+
74187424
result_in_dict = relabel_result(result, func, columns, order)
74197425
result = DataFrame(result_in_dict, index=columns)
74207426

pandas/core/indexes/datetimes.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _new_DatetimeIndex(cls, d):
7575
+ [
7676
method
7777
for method in DatetimeArray._datetimelike_methods
78-
if method not in ("tz_localize",)
78+
if method not in ("tz_localize", "tz_convert")
7979
],
8080
DatetimeArray,
8181
wrap=True,
@@ -228,6 +228,11 @@ class DatetimeIndex(DatetimeTimedeltaMixin):
228228
# --------------------------------------------------------------------
229229
# methods that dispatch to array and wrap result in DatetimeIndex
230230

231+
@doc(DatetimeArray.tz_convert)
232+
def tz_convert(self, tz) -> "DatetimeIndex":
233+
arr = self._data.tz_convert(tz)
234+
return type(self)._simple_new(arr, name=self.name)
235+
231236
@doc(DatetimeArray.tz_localize)
232237
def tz_localize(
233238
self, tz, ambiguous="raise", nonexistent="raise"

pandas/core/tools/datetimes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,7 @@ def _convert_listlike_datetimes(
307307
if not isinstance(arg, (DatetimeArray, DatetimeIndex)):
308308
return DatetimeIndex(arg, tz=tz, name=name)
309309
if tz == "utc":
310-
# error: Item "DatetimeIndex" of "Union[DatetimeArray, DatetimeIndex]" has
311-
# no attribute "tz_convert"
312-
arg = arg.tz_convert(None).tz_localize(tz) # type: ignore[union-attr]
310+
arg = arg.tz_convert(None).tz_localize(tz)
313311
return arg
314312

315313
elif is_datetime64_ns_dtype(arg_dtype):

setup.cfg

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@ check_untyped_defs=False
157157
[mypy-pandas.core.computation.scope]
158158
check_untyped_defs=False
159159

160-
[mypy-pandas.core.dtypes.cast]
161-
check_untyped_defs=False
162-
163160
[mypy-pandas.core.frame]
164161
check_untyped_defs=False
165162

0 commit comments

Comments
 (0)