Skip to content

Commit d88b23c

Browse files
committed
Merge remote-tracking branch 'upstream/master' into str_infer
2 parents 1ff880a + 28a42da commit d88b23c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1001
-436
lines changed

asv_bench/benchmarks/reshape.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,33 @@ def time_unstack(self):
4949

5050
class Unstack(object):
5151

52-
def setup(self):
52+
params = ['int', 'category']
53+
54+
def setup(self, dtype):
5355
m = 100
5456
n = 1000
5557

5658
levels = np.arange(m)
5759
index = MultiIndex.from_product([levels] * 2)
5860
columns = np.arange(n)
59-
values = np.arange(m * m * n).reshape(m * m, n)
61+
if dtype == 'int':
62+
values = np.arange(m * m * n).reshape(m * m, n)
63+
else:
64+
# the category branch is ~20x slower than int. So we
65+
# cut down the size a bit. Now it's only ~3x slower.
66+
n = 50
67+
columns = columns[:n]
68+
indices = np.random.randint(0, 52, size=(m * m, n))
69+
values = np.take(list(string.ascii_letters), indices)
70+
values = [pd.Categorical(v) for v in values.T]
71+
6072
self.df = DataFrame(values, index, columns)
6173
self.df2 = self.df.iloc[:-1]
6274

63-
def time_full_product(self):
75+
def time_full_product(self, dtype):
6476
self.df.unstack()
6577

66-
def time_without_last_row(self):
78+
def time_without_last_row(self, dtype):
6779
self.df2.unstack()
6880

6981

ci/azure/linux.yml

+25
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,28 @@ jobs:
5454
inputs:
5555
testResultsFiles: 'test-data-*.xml'
5656
testRunTitle: 'Linux'
57+
- powershell: |
58+
$junitXml = "test-data-single.xml"
59+
$(Get-Content $junitXml | Out-String) -match 'failures="(.*?)"'
60+
if ($matches[1] -eq 0)
61+
{
62+
Write-Host "No test failures in test-data-single"
63+
}
64+
else
65+
{
66+
# note that this will produce $LASTEXITCODE=1
67+
Write-Error "$($matches[1]) tests failed"
68+
}
69+
70+
$junitXmlMulti = "test-data-multiple.xml"
71+
$(Get-Content $junitXmlMulti | Out-String) -match 'failures="(.*?)"'
72+
if ($matches[1] -eq 0)
73+
{
74+
Write-Host "No test failures in test-data-multi"
75+
}
76+
else
77+
{
78+
# note that this will produce $LASTEXITCODE=1
79+
Write-Error "$($matches[1]) tests failed"
80+
}
81+
displayName: Check for test failures

ci/azure/macos.yml

+25
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,28 @@ jobs:
4141
inputs:
4242
testResultsFiles: 'test-data-*.xml'
4343
testRunTitle: 'MacOS-35'
44+
- powershell: |
45+
$junitXml = "test-data-single.xml"
46+
$(Get-Content $junitXml | Out-String) -match 'failures="(.*?)"'
47+
if ($matches[1] -eq 0)
48+
{
49+
Write-Host "No test failures in test-data-single"
50+
}
51+
else
52+
{
53+
# note that this will produce $LASTEXITCODE=1
54+
Write-Error "$($matches[1]) tests failed"
55+
}
56+
57+
$junitXmlMulti = "test-data-multiple.xml"
58+
$(Get-Content $junitXmlMulti | Out-String) -match 'failures="(.*?)"'
59+
if ($matches[1] -eq 0)
60+
{
61+
Write-Host "No test failures in test-data-multi"
62+
}
63+
else
64+
{
65+
# note that this will produce $LASTEXITCODE=1
66+
Write-Error "$($matches[1]) tests failed"
67+
}
68+
displayName: Check for test failures

ci/azure/windows-py27.yml

+13
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,16 @@ jobs:
4343
inputs:
4444
testResultsFiles: 'test-data.xml'
4545
testRunTitle: 'Windows 27'
46+
- powershell: |
47+
$junitXml = "test-data.xml"
48+
$(Get-Content $junitXml | Out-String) -match 'failures="(.*?)"'
49+
if ($matches[1] -eq 0)
50+
{
51+
Write-Host "No test failures in test-data"
52+
}
53+
else
54+
{
55+
# note that this will produce $LASTEXITCODE=1
56+
Write-Error "$($matches[1]) tests failed"
57+
}
58+
displayName: Check for test failures

ci/azure/windows.yml

+13
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,16 @@ jobs:
3434
inputs:
3535
testResultsFiles: 'test-data.xml'
3636
testRunTitle: 'Windows 36'
37+
- powershell: |
38+
$junitXml = "test-data.xml"
39+
$(Get-Content $junitXml | Out-String) -match 'failures="(.*?)"'
40+
if ($matches[1] -eq 0)
41+
{
42+
Write-Host "No test failures in test-data"
43+
}
44+
else
45+
{
46+
# note that this will produce $LASTEXITCODE=1
47+
Write-Error "$($matches[1]) tests failed"
48+
}
49+
displayName: Check for test failures

ci/deps/azure-macos-35.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
- nomkl
1313
- numexpr
1414
- numpy=1.12.0
15-
- openpyxl
15+
- openpyxl=2.5.5
1616
- pytables
1717
- python=3.5*
1818
- pytz

doc/source/whatsnew/v0.24.0.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ update the ``ExtensionDtype._metadata`` tuple to match the signature of your
855855
- Updated the ``.type`` attribute for ``PeriodDtype``, ``DatetimeTZDtype``, and ``IntervalDtype`` to be instances of the dtype (``Period``, ``Timestamp``, and ``Interval`` respectively) (:issue:`22938`)
856856
- :func:`ExtensionArray.isna` is allowed to return an ``ExtensionArray`` (:issue:`22325`).
857857
- Support for reduction operations such as ``sum``, ``mean`` via opt-in base class method override (:issue:`22762`)
858-
- :meth:`Series.unstack` no longer converts extension arrays to object-dtype ndarrays. The output ``DataFrame`` will now have the same dtype as the input. This changes behavior for Categorical and Sparse data (:issue:`23077`).
858+
- :meth:`Series.unstack` and :meth:`DataFrame.unstack` no longer convert extension arrays to object-dtype ndarrays. Each column in the output ``DataFrame`` will now have the same dtype as the input (:issue:`23077`).
859859
- Bug when grouping :meth:`Dataframe.groupby()` and aggregating on ``ExtensionArray`` it was not returning the actual ``ExtensionArray`` dtype (:issue:`23227`).
860860

861861
.. _whatsnew_0240.api.incompatibilities:
@@ -1092,6 +1092,7 @@ Categorical
10921092
- Bug when indexing with a boolean-valued ``Categorical``. Now a boolean-valued ``Categorical`` is treated as a boolean mask (:issue:`22665`)
10931093
- Constructing a :class:`CategoricalIndex` with empty values and boolean categories was raising a ``ValueError`` after a change to dtype coercion (:issue:`22702`).
10941094
- Bug in :meth:`Categorical.take` with a user-provided ``fill_value`` not encoding the ``fill_value``, which could result in a ``ValueError``, incorrect results, or a segmentation fault (:issue:`23296`).
1095+
- In meth:`Series.unstack`, specifying a ``fill_value`` not present in the categories now raises a ``TypeError`` rather than ignoring the ``fill_value`` (:issue:`23284`)
10951096
- Bug when resampling :meth:`Dataframe.resample()` and aggregating on categorical data, the categorical dtype was getting lost. (:issue:`23227`)
10961097

10971098
Datetimelike
@@ -1123,6 +1124,7 @@ Datetimelike
11231124
- Bug in :func:`date_range` with frequency of ``Day`` or higher where dates sufficiently far in the future could wrap around to the past instead of raising ``OutOfBoundsDatetime`` (:issue:`14187`)
11241125
- Bug in :class:`PeriodIndex` with attribute ``freq.n`` greater than 1 where adding a :class:`DateOffset` object would return incorrect results (:issue:`23215`)
11251126
- Bug in :class:`Series` that interpreted string indices as lists of characters when setting datetimelike values (:issue:`23451`)
1127+
- Bug in :class:`Timestamp` constructor which would drop the frequency of an input :class:`Timestamp` (:issue:`22311`)
11261128

11271129
Timedelta
11281130
^^^^^^^^^
@@ -1207,6 +1209,7 @@ Indexing
12071209
^^^^^^^^
12081210

12091211
- The traceback from a ``KeyError`` when asking ``.loc`` for a single missing label is now shorter and more clear (:issue:`21557`)
1212+
- :class:`PeriodIndex` now emits a ``KeyError`` when a malformed string is looked up, which is consistent with the behavior of :class:`DateTimeIndex` (:issue:`22803`)
12101213
- When ``.ix`` is asked for a missing integer label in a :class:`MultiIndex` with a first level of integer type, it now raises a ``KeyError``, consistently with the case of a flat :class:`Int64Index`, rather than falling back to positional indexing (:issue:`21593`)
12111214
- Bug in :meth:`DatetimeIndex.reindex` when reindexing a tz-naive and tz-aware :class:`DatetimeIndex` (:issue:`8306`)
12121215
- Bug in :meth:`Series.reindex` when reindexing an empty series with a ``datetime64[ns, tz]`` dtype (:issue:`20869`)
@@ -1223,7 +1226,7 @@ Indexing
12231226
- Bug in `MultiIndex.set_levels` when levels value is not subscriptable (:issue:`23273`)
12241227
- Bug where setting a timedelta column by ``Index`` causes it to be casted to double, and therefore lose precision (:issue:`23511`)
12251228
- Bug in :func:`Index.union` and :func:`Index.intersection` where name of the ``Index`` of the result was not computed correctly for certain cases (:issue:`9943`, :issue:`9862`)
1226-
1229+
- Bug in :class:`Index` slicing with boolean :class:`Index` may raise ``TypeError`` (:issue:`22533`)
12271230

12281231
Missing
12291232
^^^^^^^

pandas/_libs/tslibs/timestamps.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ from cpython.datetime cimport (datetime,
1616
PyDateTime_IMPORT
1717

1818
from util cimport (is_datetime64_object, is_timedelta64_object,
19-
is_integer_object, is_string_object, is_array)
19+
is_integer_object, is_string_object, is_array,
20+
is_offset_object)
2021

2122
cimport ccalendar
2223
from conversion import tz_localize_to_utc, normalize_i8_timestamps
@@ -734,6 +735,9 @@ class Timestamp(_Timestamp):
734735

735736
if is_string_object(freq):
736737
freq = to_offset(freq)
738+
elif not is_offset_object(freq):
739+
# GH 22311: Try to extract the frequency of a given Timestamp input
740+
freq = getattr(ts_input, 'freq', None)
737741

738742
return create_timestamp_from_ts(ts.value, ts.dts, ts.tzinfo, freq)
739743

pandas/compat/numpy/function.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
"""
2020

2121
from numpy import ndarray
22-
from pandas.util._validators import (validate_args, validate_kwargs,
23-
validate_args_and_kwargs)
24-
from pandas.errors import UnsupportedFunctionCall
25-
from pandas.core.dtypes.common import is_integer, is_bool
22+
2623
from pandas.compat import OrderedDict
24+
from pandas.errors import UnsupportedFunctionCall
25+
from pandas.util._validators import (
26+
validate_args, validate_args_and_kwargs, validate_kwargs)
27+
28+
from pandas.core.dtypes.common import is_bool, is_integer
2729

2830

2931
class CompatValidator(object):

pandas/compat/pickle_compat.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
Support pre-0.12 series pickle compatibility.
33
"""
44

5-
import sys
6-
import pandas # noqa
75
import copy
86
import pickle as pkl
9-
from pandas import compat, Index
10-
from pandas.compat import u, string_types # noqa
7+
import sys
8+
9+
from pandas.compat import string_types, u # noqa
10+
11+
import pandas # noqa
12+
from pandas import Index, compat
1113

1214

1315
def load_reduce(self):

pandas/core/arrays/datetimelike.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def __getitem__(self, key):
161161
return self._box_func(val)
162162

163163
if com.is_bool_indexer(key):
164-
key = np.asarray(key)
164+
key = np.asarray(key, dtype=bool)
165165
if key.all():
166166
key = slice(0, None, None)
167167
else:

0 commit comments

Comments
 (0)