Skip to content

TST: Enable Index dtype comparison by default #11588

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 1 commit into from
Nov 17, 2015
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
3 changes: 3 additions & 0 deletions doc/source/whatsnew/v0.17.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,6 @@ Bug Fixes
- Bug in the link-time error caused by C ``inline`` functions on FreeBSD 10+ (with ``clang``) (:issue:`10510`)
- Bug in ``DataFrame.to_csv`` in passing through arguments for formatting ``MultiIndexes``, including ``date_format`` (:issue:`7791`)
- Bug in ``DataFrame.join()`` with ``how='right'`` producing a ``TypeError`` (:issue:`11519`)
- Bug in ``Series.quantile`` with empty list results has ``Index`` with ``object`` dtype (:issue:`11588`)
- Bug in ``pd.merge`` results in empty ``Int64Index`` rather than ``Index(dtype=object)`` when the merge result is empty (:issue:`11588`)

22 changes: 11 additions & 11 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,7 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
avoid duplicating data
method : {None, 'backfill'/'bfill', 'pad'/'ffill', 'nearest'}, optional
method to use for filling holes in reindexed DataFrame.
Please note: this is only applicable to DataFrames/Series with a
Please note: this is only applicable to DataFrames/Series with a
monotonically increasing/decreasing index.
* default: don't fill gaps
* pad / ffill: propagate last valid observation forward to next valid
Expand Down Expand Up @@ -1822,7 +1822,7 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,

Create a new index and reindex the dataframe. By default
values in the new index that do not have corresponding
records in the dataframe are assigned ``NaN``.
records in the dataframe are assigned ``NaN``.

>>> new_index= ['Safari', 'Iceweasel', 'Comodo Dragon', 'IE10',
... 'Chrome']
Expand All @@ -1836,8 +1836,8 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,

We can fill in the missing values by passing a value to
the keyword ``fill_value``. Because the index is not monotonically
increasing or decreasing, we cannot use arguments to the keyword
``method`` to fill the ``NaN`` values.
increasing or decreasing, we cannot use arguments to the keyword
``method`` to fill the ``NaN`` values.

>>> df.reindex(new_index, fill_value=0)
http_status response_time
Expand All @@ -1855,8 +1855,8 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
IE10 404 0.08
Chrome 200 0.02

To further illustrate the filling functionality in
``reindex``, we will create a dataframe with a
To further illustrate the filling functionality in
``reindex``, we will create a dataframe with a
monotonically increasing index (for example, a sequence
of dates).

Expand All @@ -1873,7 +1873,7 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
2010-01-06 88

Suppose we decide to expand the dataframe to cover a wider
date range.
date range.

>>> date_index2 = pd.date_range('12/29/2009', periods=10, freq='D')
>>> df2.reindex(date_index2)
Expand All @@ -1890,10 +1890,10 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
2010-01-07 NaN

The index entries that did not have a value in the original data frame
(for example, '2009-12-29') are by default filled with ``NaN``.
(for example, '2009-12-29') are by default filled with ``NaN``.
If desired, we can fill in the missing values using one of several
options.
options.

For example, to backpropagate the last valid value to fill the ``NaN``
values, pass ``bfill`` as an argument to the ``method`` keyword.

Expand All @@ -1911,7 +1911,7 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
2010-01-07 NaN

Please note that the ``NaN`` value present in the original dataframe
(at index value 2010-01-03) will not be filled by any of the
(at index value 2010-01-03) will not be filled by any of the
value propagation schemes. This is because filling while reindexing
does not look at dataframe values, but only compares the original and
desired indexes. If you do want to fill in the ``NaN`` values present
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,15 +524,15 @@ def _align_series(self, indexer, ser, multiindex_indexer=False):
Parameters
----------
indexer : tuple, slice, scalar
The indexer used to get the locations that will be set to
The indexer used to get the locations that will be set to
`ser`

ser : pd.Series
The values to assign to the locations specified by `indexer`

multiindex_indexer : boolean, optional
Defaults to False. Should be set to True if `indexer` was from
a `pd.MultiIndex`, to avoid unnecessary broadcasting.
a `pd.MultiIndex`, to avoid unnecessary broadcasting.


Returns:
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
_maybe_box_datetimelike, ABCDataFrame,
_dict_compat)
from pandas.core.index import (Index, MultiIndex, InvalidIndexError,
_ensure_index)
Float64Index, _ensure_index)
from pandas.core.indexing import check_bool_indexer, maybe_convert_indices
from pandas.core import generic, base
from pandas.core.internals import SingleBlockManager
Expand Down Expand Up @@ -1271,6 +1271,8 @@ def quantile(self, q=0.5):
def multi(values, qs):
if com.is_list_like(qs):
values = [_quantile(values, x*100) for x in qs]
# let empty result to be Float64Index
qs = Float64Index(qs)
return self._constructor(values, index=qs, name=self.name)
else:
return _quantile(values, qs*100)
Expand Down
11 changes: 7 additions & 4 deletions pandas/io/tests/test_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,8 @@ def test_int_types(self):
# test with convert_float=False comes back as float
float_frame = frame.astype(float)
recons = read_excel(path, 'test1', convert_float=False)
tm.assert_frame_equal(recons, float_frame)
tm.assert_frame_equal(recons, float_frame,
check_index_type=False, check_column_type=False)

def test_float_types(self):
_skip_if_no_xlrd()
Expand Down Expand Up @@ -1186,9 +1187,11 @@ def test_to_excel_output_encoding(self):
_skip_if_no_xlrd()
ext = self.ext
filename = '__tmp_to_excel_float_format__.' + ext
df = DataFrame([[u('\u0192'), u('\u0193'), u('\u0194')],
[u('\u0195'), u('\u0196'), u('\u0197')]],
index=[u('A\u0192'), 'B'], columns=[u('X\u0193'), 'Y', 'Z'])

# avoid mixed inferred_type
df = DataFrame([[u'\u0192', u'\u0193', u'\u0194'],
[u'\u0195', u'\u0196', u'\u0197']],
index=[u'A\u0192', u'B'], columns=[u'X\u0193', u'Y', u'Z'])

with ensure_clean(filename) as filename:
df.to_excel(filename, sheet_name='TestSheet', encoding='utf8')
Expand Down
Loading