Skip to content

Commit 9f42d0c

Browse files
author
Camilo Cota
committed
double backticks around decimal and engine='python'
2 parents dc8ca62 + b88eb35 commit 9f42d0c

Some content is hidden

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

48 files changed

+1921
-647
lines changed

asv_bench/benchmarks/groupby.py

+15
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,21 @@ def setup(self):
773773
def time_groupby_transform_series2(self):
774774
self.df.groupby('id')['val'].transform(np.mean)
775775

776+
777+
class groupby_transform_dataframe(object):
778+
# GH 12737
779+
goal_time = 0.2
780+
781+
def setup(self):
782+
self.df = pd.DataFrame({'group': np.repeat(np.arange(1000), 10),
783+
'B': np.nan,
784+
'C': np.nan})
785+
self.df.ix[4::10, 'B':'C'] = 5
786+
787+
def time_groupby_transform_dataframe(self):
788+
self.df.groupby('group').transform('first')
789+
790+
776791
class groupby_transform_cythonized(object):
777792
goal_time = 0.2
778793

doc/source/timeseries.rst

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ time.
9898
9999
pd.Timestamp(datetime(2012, 5, 1))
100100
pd.Timestamp('2012-05-01')
101+
pd.Timestamp(2012, 5, 1)
101102
102103
However, in many cases it is more natural to associate things like change
103104
variables with a time span instead. The span represented by ``Period`` can be

doc/source/whatsnew/v0.18.2.txt

+40-4
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,22 @@ Other enhancements
3232
- The ``.tz_localize()`` method of ``DatetimeIndex`` and ``Timestamp`` has gained the ``errors`` keyword, so you can potentially coerce nonexistent timestamps to ``NaT``. The default behaviour remains to raising a ``NonExistentTimeError`` (:issue:`13057`)
3333

3434
- ``Index`` now supports ``.str.extractall()`` which returns ``DataFrame``, see :ref:`Extract all matches in each subject (extractall) <text.extractall>` (:issue:`10008`, :issue:`13156`)
35+
- ``.to_hdf/read_hdf()`` now accept path objects (e.g. ``pathlib.Path``, ``py.path.local``) for the file path (:issue:`11773`)
3536

3637
.. ipython:: python
3738

3839
idx = pd.Index(["a1a2", "b1", "c1"])
3940
idx.str.extractall("[ab](?P<digit>\d)")
4041

41-
- The ``pd.read_csv()`` with engine='python' has gained support for the decimal option (:issue:`12933`)
42+
- ``Timestamp``s can now accept positional and keyword parameters like :func:`datetime.datetime` (:issue:`10758`, :issue:`11630`)
43+
44+
.. ipython:: python
45+
46+
pd.Timestamp(2012, 1, 1)
47+
48+
pd.Timestamp(year=2012, month=1, day=1, hour=8, minute=30)
49+
50+
- The ``pd.read_csv()`` with ``engine='python'`` has gained support for the ``decimal`` option (:issue:`12933`)
4251

4352
.. _whatsnew_0182.api:
4453

@@ -47,6 +56,8 @@ API changes
4756

4857

4958
- Non-convertible dates in an excel date column will be returned without conversion and the column will be ``object`` dtype, rather than raising an exception (:issue:`10001`)
59+
- An ``UnsupportedFunctionCall`` error is now raised if numpy ufuncs like ``np.mean`` are called on groupby or resample objects (:issue:`12811`)
60+
- Calls to ``.sample()`` will respect the random seed set via ``numpy.random.seed(n)`` (:issue:`13161`)
5061

5162

5263
.. _whatsnew_0182.api.tolist:
@@ -77,13 +88,26 @@ New Behavior:
7788
type(s.tolist()[0])
7889

7990

91+
.. _whatsnew_0182.api.to_datetime_coerce:
92+
93+
``.to_datetime()`` when coercing
94+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8095

96+
A bug is fixed in ``.to_datetime()`` when passing integers or floats, and no ``unit`` and ``errors='coerce'`` (:issue:`13180`).
97+
Previously if ``.to_datetime()`` encountered mixed integers/floats and strings, but no datetimes with ``errors='coerce'`` it would convert all to ``NaT``.
8198

99+
Previous Behavior:
82100

101+
.. code-block:: ipython
83102

103+
In [2]: pd.to_datetime([1, 'foo'], errors='coerce')
104+
Out[2]: DatetimeIndex(['NaT', 'NaT'], dtype='datetime64[ns]', freq=None)
84105

106+
This will now convert integers/floats with the default unit of ``ns``.
85107

108+
.. ipython:: python
86109

110+
pd.to_datetime([1, 'foo'], errors='coerce')
87111

88112
.. _whatsnew_0182.api.other:
89113

@@ -106,32 +130,39 @@ Performance Improvements
106130
- increased performance of ``DataFrame.quantile()`` as it now operates per-block (:issue:`11623`)
107131

108132

109-
133+
- Improved performance of ``DataFrameGroupBy.transform`` (:issue:`12737`)
110134

111135

112136
.. _whatsnew_0182.bug_fixes:
113137

114138
Bug Fixes
115139
~~~~~~~~~
116140

141+
- Bug in ``io.json.json_normalize()``, where non-ascii keys raised an exception (:issue:`13213`)
117142
- Bug in ``SparseSeries`` with ``MultiIndex`` ``[]`` indexing may raise ``IndexError`` (:issue:`13144`)
118143
- Bug in ``SparseSeries`` with ``MultiIndex`` ``[]`` indexing result may have normal ``Index`` (:issue:`13144`)
119144
- Bug in ``SparseDataFrame`` in which ``axis=None`` did not default to ``axis=0`` (:issue:`13048`)
145+
- Bug in ``SparseSeries`` and ``SparseDataFrame`` creation with ``object`` dtype may raise ``TypeError`` (:issue:`11633`)
120146
- Bug when passing a not-default-indexed ``Series`` as ``xerr`` or ``yerr`` in ``.plot()`` (:issue:`11858`)
147+
- Bug in matplotlib ``AutoDataFormatter``; this restores the second scaled formatting and re-adds micro-second scaled formatting (:issue:`13131`)
121148

122149

123150
- Bug in ``.groupby(..).resample(..)`` when the same object is called multiple times (:issue:`13174`)
151+
- Bug in ``.to_records()`` when index name is a unicode string (:issue: `13172`)
124152

153+
- Bug in calling ``.memory_usage()`` on object which doesn't implement (:issue:`12924`)
125154

126155
- Regression in ``Series.quantile`` with nans (also shows up in ``.median()`` and ``.describe()``); furthermore now names the ``Series`` with the quantile (:issue:`13098`, :issue:`13146`)
127156

128-
157+
- Bug in ``SeriesGroupBy.transform`` with datetime values and missing groups (:issue:`13191`)
129158

130159
- Bug in ``Series.str.extractall()`` with ``str`` index raises ``ValueError`` (:issue:`13156`)
131160

132161

133162
- Bug in ``PeriodIndex`` and ``Period`` subtraction raises ``AttributeError`` (:issue:`13071`)
134-
163+
- Bug in ``.resample(..)`` with a ``PeriodIndex`` not changing its ``freq`` appropriately when empty (:issue:`13067`)
164+
- Bug in ``PeriodIndex`` construction returning a ``float64`` index in some circumstances (:issue:`13067`)
165+
- Bug in ``.resample(..)`` with a ``PeriodIndex`` not retaining its type or name with an empty ``DataFrame``appropriately when empty (:issue:`13212`)
135166

136167

137168

@@ -149,4 +180,9 @@ Bug Fixes
149180

150181
- Bug in ``NaT`` - ``Period`` raises ``AttributeError`` (:issue:`13071`)
151182
- Bug in ``Period`` addition raises ``TypeError`` if ``Period`` is on right hand side (:issue:`13069`)
183+
- Bug in ``Peirod`` and ``Series`` or ``Index`` comparison raises ``TypeError`` (:issue:`13200`)
152184
- Bug in ``pd.set_eng_float_format()`` that would prevent NaN's from formatting (:issue:`11981`)
185+
- Bug in ``.unstack`` with ``Categorical`` dtype resets ``.ordered`` to ``True`` (:issue:`13249`)
186+
187+
188+
- Bug in ``groupby`` where ``apply`` returns different result depending on whether first result is ``None`` or not (:issue:`12824`)

doc/source/whatsnew/v0.19.0.txt

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
.. _whatsnew_0190:
2+
3+
v0.19.0 (????, 2016)
4+
--------------------
5+
6+
This is a major release from 0.18.2 and includes a small number of API changes, several new features,
7+
enhancements, and performance improvements along with a large number of bug fixes. We recommend that all
8+
users upgrade to this version.
9+
10+
Highlights include:
11+
12+
13+
Check the :ref:`API Changes <whatsnew_0190.api_breaking>` and :ref:`deprecations <whatsnew_0190.deprecations>` before updating.
14+
15+
.. contents:: What's new in v0.19.0
16+
:local:
17+
:backlinks: none
18+
19+
.. _whatsnew_0190.enhancements:
20+
21+
New features
22+
~~~~~~~~~~~~
23+
24+
25+
26+
27+
28+
.. _whatsnew_0190.enhancements.other:
29+
30+
Other enhancements
31+
^^^^^^^^^^^^^^^^^^
32+
33+
34+
35+
36+
37+
38+
.. _whatsnew_0190.api_breaking:
39+
40+
Backwards incompatible API changes
41+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42+
43+
.. _whatsnew_0190.api:
44+
45+
46+
47+
48+
49+
50+
Other API Changes
51+
^^^^^^^^^^^^^^^^^
52+
53+
.. _whatsnew_0190.deprecations:
54+
55+
Deprecations
56+
^^^^^^^^^^^^
57+
58+
59+
60+
61+
62+
.. _whatsnew_0190.prior_deprecations:
63+
64+
Removal of prior version deprecations/changes
65+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66+
67+
68+
69+
70+
71+
.. _whatsnew_0190.performance:
72+
73+
Performance Improvements
74+
~~~~~~~~~~~~~~~~~~~~~~~~
75+
76+
77+
78+
79+
80+
.. _whatsnew_0190.bug_fixes:
81+
82+
Bug Fixes
83+
~~~~~~~~~

pandas/compat/numpy/function.py

+75-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from numpy import ndarray
2222
from pandas.util.validators import (validate_args, validate_kwargs,
2323
validate_args_and_kwargs)
24-
from pandas.core.common import is_integer
24+
from pandas.core.common import is_integer, UnsupportedFunctionCall
2525
from pandas.compat import OrderedDict
2626

2727

@@ -245,3 +245,77 @@ def validate_transpose_for_generic(inst, kwargs):
245245
msg += " for {klass} instances".format(klass=klass)
246246

247247
raise ValueError(msg)
248+
249+
250+
def validate_window_func(name, args, kwargs):
251+
numpy_args = ('axis', 'dtype', 'out')
252+
msg = ("numpy operations are not "
253+
"valid with window objects. "
254+
"Use .{func}() directly instead ".format(func=name))
255+
256+
if len(args) > 0:
257+
raise UnsupportedFunctionCall(msg)
258+
259+
for arg in numpy_args:
260+
if arg in kwargs:
261+
raise UnsupportedFunctionCall(msg)
262+
263+
264+
def validate_rolling_func(name, args, kwargs):
265+
numpy_args = ('axis', 'dtype', 'out')
266+
msg = ("numpy operations are not "
267+
"valid with window objects. "
268+
"Use .rolling(...).{func}() instead ".format(func=name))
269+
270+
if len(args) > 0:
271+
raise UnsupportedFunctionCall(msg)
272+
273+
for arg in numpy_args:
274+
if arg in kwargs:
275+
raise UnsupportedFunctionCall(msg)
276+
277+
278+
def validate_expanding_func(name, args, kwargs):
279+
numpy_args = ('axis', 'dtype', 'out')
280+
msg = ("numpy operations are not "
281+
"valid with window objects. "
282+
"Use .expanding(...).{func}() instead ".format(func=name))
283+
284+
if len(args) > 0:
285+
raise UnsupportedFunctionCall(msg)
286+
287+
for arg in numpy_args:
288+
if arg in kwargs:
289+
raise UnsupportedFunctionCall(msg)
290+
291+
292+
def validate_groupby_func(name, args, kwargs):
293+
"""
294+
'args' and 'kwargs' should be empty because all of
295+
their necessary parameters are explicitly listed in
296+
the function signature
297+
"""
298+
if len(args) + len(kwargs) > 0:
299+
raise UnsupportedFunctionCall((
300+
"numpy operations are not valid "
301+
"with groupby. Use .groupby(...)."
302+
"{func}() instead".format(func=name)))
303+
304+
RESAMPLER_NUMPY_OPS = ('min', 'max', 'sum', 'prod',
305+
'mean', 'std', 'var')
306+
307+
308+
def validate_resampler_func(method, args, kwargs):
309+
"""
310+
'args' and 'kwargs' should be empty because all of
311+
their necessary parameters are explicitly listed in
312+
the function signature
313+
"""
314+
if len(args) + len(kwargs) > 0:
315+
if method in RESAMPLER_NUMPY_OPS:
316+
raise UnsupportedFunctionCall((
317+
"numpy operations are not valid "
318+
"with resample. Use .resample(...)."
319+
"{func}() instead".format(func=method)))
320+
else:
321+
raise TypeError("too many arguments passed in")

pandas/core/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def __sizeof__(self):
127127

128128
# no memory_usage attribute, so fall back to
129129
# object's 'sizeof'
130-
return super(self, PandasObject).__sizeof__()
130+
return super(PandasObject, self).__sizeof__()
131131

132132

133133
class NoNewAttributesMixin(object):

pandas/core/common.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class AmbiguousIndexError(PandasError, KeyError):
4141
pass
4242

4343

44+
class UnsupportedFunctionCall(ValueError):
45+
pass
46+
47+
4448
class AbstractMethodError(NotImplementedError):
4549
"""Raise this error instead of NotImplementedError for abstract methods
4650
while keeping compatibility with Python 2 and Python 3.
@@ -2058,7 +2062,7 @@ def _random_state(state=None):
20582062
state : int, np.random.RandomState, None.
20592063
If receives an int, passes to np.random.RandomState() as seed.
20602064
If receives an np.random.RandomState object, just returns object.
2061-
If receives `None`, returns an np.random.RandomState object.
2065+
If receives `None`, returns np.random.
20622066
If receives anything else, raises an informative ValueError.
20632067
Default None.
20642068
@@ -2072,7 +2076,7 @@ def _random_state(state=None):
20722076
elif isinstance(state, np.random.RandomState):
20732077
return state
20742078
elif state is None:
2075-
return np.random.RandomState()
2079+
return np.random
20762080
else:
20772081
raise ValueError("random_state must be an integer, a numpy "
20782082
"RandomState, or None")

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ def to_records(self, index=True, convert_datetime64=True):
10621062
count += 1
10631063
elif index_names[0] is None:
10641064
index_names = ['index']
1065-
names = index_names + lmap(str, self.columns)
1065+
names = lmap(str, index_names) + lmap(str, self.columns)
10661066
else:
10671067
arrays = [self[c].get_values() for c in self.columns]
10681068
names = lmap(str, self.columns)

pandas/core/generic.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -5299,7 +5299,7 @@ def _make_stat_function(cls, name, name1, name2, axis_descr, desc, f):
52995299
@Appender(_num_doc)
53005300
def stat_func(self, axis=None, skipna=None, level=None, numeric_only=None,
53015301
**kwargs):
5302-
nv.validate_stat_func(tuple(), kwargs)
5302+
nv.validate_stat_func(tuple(), kwargs, fname=name)
53035303
if skipna is None:
53045304
skipna = True
53055305
if axis is None:
@@ -5319,7 +5319,7 @@ def _make_stat_function_ddof(cls, name, name1, name2, axis_descr, desc, f):
53195319
@Appender(_num_ddof_doc)
53205320
def stat_func(self, axis=None, skipna=None, level=None, ddof=1,
53215321
numeric_only=None, **kwargs):
5322-
nv.validate_stat_ddof_func(tuple(), kwargs)
5322+
nv.validate_stat_ddof_func(tuple(), kwargs, fname=name)
53235323
if skipna is None:
53245324
skipna = True
53255325
if axis is None:
@@ -5340,7 +5340,7 @@ def _make_cum_function(cls, name, name1, name2, axis_descr, desc, accum_func,
53405340
@Appender("Return cumulative {0} over requested axis.".format(name) +
53415341
_cnum_doc)
53425342
def cum_func(self, axis=None, dtype=None, out=None, skipna=True, **kwargs):
5343-
nv.validate_cum_func(tuple(), kwargs)
5343+
nv.validate_cum_func(tuple(), kwargs, fname=name)
53445344
if axis is None:
53455345
axis = self._stat_axis_number
53465346
else:
@@ -5374,7 +5374,7 @@ def _make_logical_function(cls, name, name1, name2, axis_descr, desc, f):
53745374
@Appender(_bool_doc)
53755375
def logical_func(self, axis=None, bool_only=None, skipna=None, level=None,
53765376
**kwargs):
5377-
nv.validate_logical_func(tuple(), kwargs)
5377+
nv.validate_logical_func(tuple(), kwargs, fname=name)
53785378
if skipna is None:
53795379
skipna = True
53805380
if axis is None:

0 commit comments

Comments
 (0)