Skip to content

Commit 70510be

Browse files
committed
Merge remote-tracking branch 'upstream/master' into Zac-HD-hypothesis
2 parents 835f352 + 55d176d commit 70510be

File tree

9 files changed

+47
-26
lines changed

9 files changed

+47
-26
lines changed

ci/circle-27-compat.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77
- cython=0.28.2
88
- jinja2=2.8
99
- numexpr=2.4.4 # we test that we correctly don't use an unsupported numexpr
10-
- numpy=1.9.2
10+
- numpy=1.9.3
1111
- openpyxl
1212
- psycopg2
1313
- pytables=3.2.2

ci/doctests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if [ "$DOCTEST" ]; then
2828
fi
2929

3030
pytest --doctest-modules -v pandas/core/series.py \
31-
-k"-agg -map -nlargest -nonzero -nsmallest -reindex -searchsorted -to_dict"
31+
-k"-nlargest -nonzero -nsmallest -reindex -searchsorted -to_dict"
3232

3333
if [ $? -ne "0" ]; then
3434
RET=1

ci/travis-27-locale.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dependencies:
77
- cython=0.28.2
88
- lxml
99
- matplotlib=1.4.3
10-
- numpy=1.9.2
10+
- numpy=1.9.3
1111
- openpyxl=2.4.0
1212
- python-dateutil
1313
- python-blosc

doc/source/whatsnew/v0.24.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ without timezone localization. This is inconsistent from parsing the same
239239
datetime string with :class:`Timestamp` which would preserve the UTC
240240
offset in the ``tz`` attribute. Now, :func:`to_datetime` preserves the UTC
241241
offset in the ``tz`` attribute when all the datetime strings have the same
242-
UTC offset (:issue:`17697`, :issue:`11736`)
242+
UTC offset (:issue:`17697`, :issue:`11736`, :issue:`22457`)
243243

244244
*Previous Behavior*:
245245

pandas/core/generic.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -4439,7 +4439,6 @@ def pipe(self, func, *args, **kwargs):
44394439
- function.
44404440
- list of functions.
44414441
- dict of column names -> functions (or list of functions).
4442-
44434442
%(axis)s
44444443
*args
44454444
Positional arguments to pass to `func`.
@@ -8146,7 +8145,7 @@ def mask(self, cond, other=np.nan, inplace=False, axis=None, level=None,
81468145
Parameters
81478146
----------
81488147
periods : int
8149-
Number of periods to move, can be positive or negative
8148+
Number of periods to move, can be positive or negative.
81508149
freq : DateOffset, timedelta, or time rule string, optional
81518150
Increment to use from the tseries module or time rule (e.g. 'EOM').
81528151
See Notes.

pandas/core/series.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,6 @@ def reset_index(self, level=None, drop=False, name=None, inplace=False):
11321132
11331133
Examples
11341134
--------
1135-
11361135
>>> s = pd.Series([1, 2, 3, 4], name='foo',
11371136
... index=pd.Index(['a', 'b', 'c', 'd'], name='idx'))
11381137
@@ -3046,21 +3045,27 @@ def _gotitem(self, key, ndim, subset=None):
30463045
Examples
30473046
--------
30483047
3049-
>>> s = pd.Series(np.random.randn(10))
3048+
>>> s = pd.Series([1, 2, 3, 4])
3049+
>>> s
3050+
0 1
3051+
1 2
3052+
2 3
3053+
3 4
3054+
dtype: int64
30503055
30513056
>>> s.agg('min')
3052-
-1.3018049988556679
3057+
1
30533058
30543059
>>> s.agg(['min', 'max'])
3055-
min -1.301805
3056-
max 1.127688
3057-
dtype: float64
3060+
min 1
3061+
max 4
3062+
dtype: int64
30583063
30593064
See also
30603065
--------
3061-
pandas.Series.apply
3062-
pandas.Series.transform
3063-
3066+
pandas.Series.apply : Invoke function on a Series.
3067+
pandas.Series.transform : Transform function producing
3068+
a Series with like indexes.
30643069
""")
30653070

30663071
@Appender(_agg_doc)
@@ -3315,7 +3320,6 @@ def rename(self, index=None, **kwargs):
33153320
33163321
Examples
33173322
--------
3318-
33193323
>>> s = pd.Series([1, 2, 3])
33203324
>>> s
33213325
0 1
@@ -3337,7 +3341,6 @@ def rename(self, index=None, **kwargs):
33373341
3 2
33383342
5 3
33393343
dtype: int64
3340-
33413344
"""
33423345
kwargs['inplace'] = validate_bool_kwarg(kwargs.get('inplace', False),
33433346
'inplace')
@@ -3507,7 +3510,6 @@ def memory_usage(self, index=True, deep=False):
35073510
35083511
Examples
35093512
--------
3510-
35113513
>>> s = pd.Series(range(3))
35123514
>>> s.memory_usage()
35133515
104
@@ -3591,7 +3593,6 @@ def isin(self, values):
35913593
35923594
Examples
35933595
--------
3594-
35953596
>>> s = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama',
35963597
... 'hippo'], name='animal')
35973598
>>> s.isin(['cow', 'lama'])

pandas/core/tools/datetimes.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,25 @@ def _convert_listlike_datetimes(arg, box, format, name=None, tz=None,
275275
yearfirst=yearfirst,
276276
require_iso8601=require_iso8601
277277
)
278-
if tz_parsed is not None and box:
279-
return DatetimeIndex._simple_new(result, name=name,
280-
tz=tz_parsed)
278+
if tz_parsed is not None:
279+
if box:
280+
# We can take a shortcut since the datetime64 numpy array
281+
# is in UTC
282+
return DatetimeIndex._simple_new(result, name=name,
283+
tz=tz_parsed)
284+
else:
285+
# Convert the datetime64 numpy array to an numpy array
286+
# of datetime objects
287+
result = [Timestamp(ts, tz=tz_parsed).to_pydatetime()
288+
for ts in result]
289+
return np.array(result, dtype=object)
281290

282291
if box:
292+
# Ensure we return an Index in all cases where box=True
283293
if is_datetime64_dtype(result):
284294
return DatetimeIndex(result, tz=tz, name=name)
285295
elif is_object_dtype(result):
296+
# e.g. an Index of datetime objects
286297
from pandas import Index
287298
return Index(result, name=name)
288299
return result

pandas/tests/indexes/datetimes/test_tools.py

+11
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,17 @@ def test_iso_8601_strings_with_same_offset(self):
592592
result = DatetimeIndex([ts_str] * 2)
593593
tm.assert_index_equal(result, expected)
594594

595+
def test_iso_8601_strings_same_offset_no_box(self):
596+
# GH 22446
597+
data = ['2018-01-04 09:01:00+09:00', '2018-01-04 09:02:00+09:00']
598+
result = pd.to_datetime(data, box=False)
599+
expected = np.array([
600+
datetime(2018, 1, 4, 9, 1, tzinfo=pytz.FixedOffset(540)),
601+
datetime(2018, 1, 4, 9, 2, tzinfo=pytz.FixedOffset(540))
602+
],
603+
dtype=object)
604+
tm.assert_numpy_array_equal(result, expected)
605+
595606
def test_iso_8601_strings_with_different_offsets(self):
596607
# GH 17697, 11736
597608
ts_strings = ["2015-11-18 15:30:00+05:30",

pandas/tests/test_algos.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,9 @@ def test_datetime64_dtype_array_returned(self):
330330
'2015-01-01T00:00:00.000000000+0000'],
331331
dtype='M8[ns]')
332332

333-
dt_index = pd.to_datetime(['2015-01-03T00:00:00.000000000+0000',
334-
'2015-01-01T00:00:00.000000000+0000',
335-
'2015-01-01T00:00:00.000000000+0000'],
336-
box=False)
333+
dt_index = pd.to_datetime(['2015-01-03T00:00:00.000000000',
334+
'2015-01-01T00:00:00.000000000',
335+
'2015-01-01T00:00:00.000000000'])
337336
result = algos.unique(dt_index)
338337
tm.assert_numpy_array_equal(result, expected)
339338
assert result.dtype == expected.dtype

0 commit comments

Comments
 (0)