Skip to content

Commit 7872a3c

Browse files
committed
Fix undesired UX behavior of DataFrame output in IPython Notebook pandas-dev#10231
1 parent b144cc1 commit 7872a3c

27 files changed

+523
-129
lines changed

doc/source/groupby.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -784,11 +784,11 @@ will be (silently) dropped. Thus, this does not pose any problems:
784784
785785
df.groupby('A').std()
786786
787-
NA group handling
788-
~~~~~~~~~~~~~~~~~
787+
NA and NaT group handling
788+
~~~~~~~~~~~~~~~~~~~~~~~~~
789789

790-
If there are any NaN values in the grouping key, these will be automatically
791-
excluded. So there will never be an "NA group". This was not the case in older
790+
If there are any NaN or NaT values in the grouping key, these will be automatically
791+
excluded. So there will never be an "NA group" or "NaT group". This was not the case in older
792792
versions of pandas, but users were generally discarding the NA group anyway
793793
(and supporting it was an implementation headache).
794794

doc/source/whatsnew.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ What's New
1818

1919
These are new features and improvements of note in each release.
2020

21-
.. include:: whatsnew/v0.17.0.txt
21+
.. include:: whatsnew/v0.16.2.txt
2222

2323
.. include:: whatsnew/v0.16.1.txt
2424

doc/source/whatsnew/v0.16.2.txt

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
.. _whatsnew_0162:
2+
3+
v0.16.2 (June 12, 2015)
4+
-----------------------
5+
6+
This is a minor bug-fix release from 0.16.1 and includes a a large number of
7+
bug fixes along several new features, enhancements, and performance improvements.
8+
We recommend that all users upgrade to this version.
9+
10+
Highlights include:
11+
12+
Check the :ref:`API Changes <whatsnew_0162.api>` before updating.
13+
14+
.. contents:: What's new in v0.16.2
15+
:local:
16+
:backlinks: none
17+
18+
.. _whatsnew_0162.enhancements:
19+
20+
New features
21+
~~~~~~~~~~~~
22+
23+
.. _whatsnew_0162.enhancements.other:
24+
25+
Other enhancements
26+
^^^^^^^^^^^^^^^^^^
27+
28+
- Fix undesired UX behavior of DataFrame output in IPython Notebook. (:issue:`10231`)
29+
30+
.. _whatsnew_0162.api:
31+
32+
Backwards incompatible API changes
33+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34+
35+
.. _whatsnew_0162.api_breaking:
36+
37+
.. _whatsnew_0162.api_breaking.other:
38+
39+
Other API Changes
40+
^^^^^^^^^^^^^^^^^
41+
42+
- ``Holiday`` now raises ``NotImplementedError`` if both ``offset`` and ``observance`` are used in constructor. (:issue:`102171`)
43+
44+
.. _whatsnew_0162.performance:
45+
46+
Performance Improvements
47+
~~~~~~~~~~~~~~~~~~~~~~~~
48+
49+
- Improved ``Series.resample`` performance with dtype=datetime64[ns] (:issue:`7754`)
50+
51+
.. _whatsnew_0162.bug_fixes:
52+
53+
Bug Fixes
54+
~~~~~~~~~
55+
56+
- Bug where read_hdf store.select modifies the passed columns list when
57+
multi-indexed (:issue:`7212`)
58+
- Bug in ``Categorical`` repr with ``display.width`` of ``None`` in Python 3 (:issue:`10087`)
59+
60+
61+
- Bug in ``mean()`` where integer dtypes can overflow (:issue:`10172`)
62+
- Bug where Panel.from_dict does not set dtype when specified (:issue:`10058`)
63+
- Bug in ``Index.union`` raises ``AttributeError`` when passing array-likes. (:issue:`10149`)
64+
- Bug in ``Timestamp``'s' ``microsecond``, ``quarter``, ``dayofyear``, ``week`` and ``daysinmonth`` properties return ``np.int`` type, not built-in ``int``. (:issue:`10050`)
65+
- Bug in ``NaT`` raises ``AttributeError`` when accessing to ``daysinmonth``, ``dayofweek`` properties. (:issue:`10096`)
66+
67+
68+
- Bug in getting timezone data with ``dateutil`` on various platforms ( :issue:`9059`, :issue:`8639`, :issue:`9663`, :issue:`10121`)
69+
- Bug in display datetimes with mixed frequencies uniformly; display 'ms' datetimes to the proper precision. (:issue:`10170`)
70+
71+
- Bung in ``Series`` arithmetic methods may incorrectly hold names (:issue:`10068`)
72+
73+
- Bug in ``DatetimeIndex`` and ``TimedeltaIndex`` names are lost after timedelta arithmetics ( :issue:`9926`)
74+
75+
76+
- Bug in `Series.plot(label="LABEL")` not correctly setting the label (:issue:`10119`)
77+
78+
- Bug in `plot` not defaulting to matplotlib `axes.grid` setting (:issue:`9792`)
79+
80+
- Bug in ``Series.align`` resets ``name`` when ``fill_value`` is specified (:issue:`10067`)
81+
- Bug in ``SparseSeries.abs`` resets ``name`` (:issue:`10241`)
82+
83+
84+
- Bug in GroupBy.get_group raises ValueError when group key contains NaT (:issue:`6992`)
85+
86+
87+
- Bug where infer_freq infers timerule (WOM-5XXX) unsupported by to_offset (:issue:`9425`)

doc/source/whatsnew/v0.17.0.txt

+2-24
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
.. _whatsnew_0170:
22

3-
v0.17.0 (July ??, 2015)
3+
v0.17.0 (July 31, 2015)
44
-----------------------
55

6-
This is a major release from 0.16.1 and includes a small number of API changes, several new features,
6+
This is a major release from 0.16.2 and includes a small number of API changes, several new features,
77
enhancements, and performance improvements along with a large number of bug fixes. We recommend that all
88
users upgrade to this version.
99

@@ -53,29 +53,7 @@ Removal of prior version deprecations/changes
5353
Performance Improvements
5454
~~~~~~~~~~~~~~~~~~~~~~~~
5555

56-
- Improved ``Series.resample`` performance with dtype=datetime64[ns] (:issue:`7754`)
57-
5856
.. _whatsnew_0170.bug_fixes:
5957

6058
Bug Fixes
6159
~~~~~~~~~
62-
63-
- Bug where read_hdf store.select modifies the passed columns list when
64-
multi-indexed (:issue:`7212`)
65-
- Bug in ``Categorical`` repr with ``display.width`` of ``None`` in Python 3 (:issue:`10087`)
66-
67-
68-
- Bug where Panel.from_dict does not set dtype when specified (:issue:`10058`)
69-
- Bug in ``Timestamp``'s' ``microsecond``, ``quarter``, ``dayofyear``, ``week`` and ``daysinmonth`` properties return ``np.int`` type, not built-in ``int``. (:issue:`10050`)
70-
- Bug in ``NaT`` raises ``AttributeError`` when accessing to ``daysinmonth``, ``dayofweek`` properties. (:issue:`10096`)
71-
72-
- Bug in getting timezone data with ``dateutil`` on various platforms ( :issue:`9059`, :issue:`8639`, :issue:`9663`, :issue:`10121`)
73-
- Bug in display datetimes with mixed frequencies uniformly; display 'ms' datetimes to the proper precision. (:issue:`10170`)
74-
75-
76-
- Bug in ``DatetimeIndex`` and ``TimedeltaIndex`` names are lost after timedelta arithmetics ( :issue:`9926`)
77-
78-
- Bug in `Series.plot(label="LABEL")` not correctly setting the label (:issue:`10119`)
79-
- Bug in `plot` not defaulting to matplotlib `axes.grid` setting (:issue:`9792`)
80-
81-

pandas/core/frame.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,7 @@ def _repr_html_(self):
538538
max_cols = get_option("display.max_columns")
539539
show_dimensions = get_option("display.show_dimensions")
540540

541-
return ('<div style="max-height:1000px;'
542-
'max-width:1500px;overflow:auto;">\n' +
541+
return ('<div>\n' +
543542
self.to_html(max_rows=max_rows, max_cols=max_cols,
544543
show_dimensions=show_dimensions) + '\n</div>')
545544
else:

pandas/core/generic.py

+8-13
Original file line numberDiff line numberDiff line change
@@ -3365,11 +3365,10 @@ def _align_series(self, other, join='outer', axis=None, level=None,
33653365
level=level,
33663366
return_indexers=True)
33673367

3368-
left_result = self._reindex_indexer(join_index, lidx, copy)
3369-
right_result = other._reindex_indexer(join_index, ridx, copy)
3368+
left = self._reindex_indexer(join_index, lidx, copy)
3369+
right = other._reindex_indexer(join_index, ridx, copy)
33703370

33713371
else:
3372-
33733372
# one has > 1 ndim
33743373
fdata = self._data
33753374
if axis == 0:
@@ -3399,23 +3398,19 @@ def _align_series(self, other, join='outer', axis=None, level=None,
33993398
if copy and fdata is self._data:
34003399
fdata = fdata.copy()
34013400

3402-
left_result = DataFrame(fdata)
3401+
left = DataFrame(fdata)
34033402

34043403
if ridx is None:
3405-
right_result = other
3404+
right = other
34063405
else:
3407-
right_result = other.reindex(join_index, level=level)
3406+
right = other.reindex(join_index, level=level)
34083407

34093408
# fill
34103409
fill_na = notnull(fill_value) or (method is not None)
34113410
if fill_na:
3412-
return (left_result.fillna(fill_value, method=method, limit=limit,
3413-
axis=fill_axis),
3414-
right_result.fillna(fill_value, method=method,
3415-
limit=limit))
3416-
else:
3417-
return (left_result.__finalize__(self),
3418-
right_result.__finalize__(other))
3411+
left = left.fillna(fill_value, method=method, limit=limit, axis=fill_axis)
3412+
right = right.fillna(fill_value, method=method, limit=limit)
3413+
return (left.__finalize__(self), right.__finalize__(other))
34193414

34203415
_shared_docs['where'] = ("""
34213416
Return an object of same shape as self and whose corresponding

pandas/core/groupby.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,11 @@ def convert(key, s):
426426
return Timestamp(key).asm8
427427
return key
428428

429-
sample = next(iter(self.indices))
429+
if len(self.indices) > 0:
430+
sample = next(iter(self.indices))
431+
else:
432+
sample = None # Dummy sample
433+
430434
if isinstance(sample, tuple):
431435
if not isinstance(name, tuple):
432436
msg = ("must supply a tuple to get_group with multiple"

0 commit comments

Comments
 (0)