Skip to content

Commit 03941b1

Browse files
Merge remote-tracking branch 'upstream/master' into pr/18629
2 parents 60124ac + 1355df6 commit 03941b1

File tree

21 files changed

+607
-319
lines changed

21 files changed

+607
-319
lines changed

asv_bench/benchmarks/timedelta.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
from .pandas_vb_common import *
2-
from pandas import to_timedelta, Timestamp
1+
import numpy as np
2+
import pandas as pd
3+
4+
from pandas import to_timedelta, Timestamp, Timedelta
35

46

57
class ToTimedelta(object):
@@ -67,8 +69,8 @@ class DatetimeAccessor(object):
6769
def setup(self):
6870
self.N = 100000
6971
self.series = pd.Series(
70-
pd.timedelta_range('1 days', periods=self.N, freq='h')
71-
)
72+
pd.timedelta_range('1 days', periods=self.N, freq='h'))
73+
7274
def time_dt_accessor(self):
7375
self.series.dt
7476

asv_bench/benchmarks/timestamp.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1-
from pandas import to_timedelta, Timestamp
1+
from pandas import Timestamp
22
import pytz
33
import datetime
44

55

6+
class TimestampConstruction(object):
7+
# TODO: classmethod constructors: fromordinal, fromtimestamp...
8+
9+
def time_parse_iso8601_no_tz(self):
10+
Timestamp('2017-08-25 08:16:14')
11+
12+
def time_parse_iso8601_tz(self):
13+
Timestamp('2017-08-25 08:16:14-0500')
14+
15+
def time_parse_dateutil(self):
16+
Timestamp('2017/08/25 08:16:14 AM')
17+
18+
def time_parse_today(self):
19+
Timestamp('today')
20+
21+
def time_parse_now(self):
22+
Timestamp('now')
23+
24+
625
class TimestampProperties(object):
726
goal_time = 0.2
827

ci/lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if [ "$LINT" ]; then
2424
echo "Linting setup.py DONE"
2525

2626
echo "Linting asv_bench/benchmarks/"
27-
flake8 asv_bench/benchmarks/ --exclude=asv_bench/benchmarks/[ghijoprst]*.py --ignore=F811
27+
flake8 asv_bench/benchmarks/ --exclude=asv_bench/benchmarks/[ghijoprs]*.py --ignore=F811
2828
if [ $? -ne "0" ]; then
2929
RET=1
3030
fi

doc/source/io.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4519,6 +4519,7 @@ See the documentation for `pyarrow <http://arrow.apache.org/docs/python/>`__ and
45194519
.. note::
45204520

45214521
These engines are very similar and should read/write nearly identical parquet format files.
4522+
Currently ``pyarrow`` does not support timedelta data, and ``fastparquet`` does not support timezone aware datetimes (they are coerced to UTC).
45224523
These libraries differ by having different underlying dependencies (``fastparquet`` by using ``numba``, while ``pyarrow`` uses a c-library).
45234524

45244525
.. ipython:: python
@@ -4545,8 +4546,8 @@ Read from a parquet file.
45454546

45464547
.. ipython:: python
45474548
4548-
result = pd.read_parquet('example_pa.parquet', engine='pyarrow')
45494549
result = pd.read_parquet('example_fp.parquet', engine='fastparquet')
4550+
result = pd.read_parquet('example_pa.parquet', engine='pyarrow')
45504551
45514552
result.dtypes
45524553

doc/source/whatsnew/v0.21.1.txt

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,23 @@
33
v0.21.1
44
-------
55

6-
This is a minor release from 0.21.1 and includes a number of deprecations, new
7-
features, enhancements, and performance improvements along with a large number
8-
of bug fixes. We recommend that all users upgrade to this version.
6+
This is a minor bug-fix release in the 0.21.x series and includes some small regression fixes,
7+
bug fixes and performance improvements.
8+
We recommend that all users upgrade to this version.
9+
10+
Highlights include:
11+
12+
- Temporarily restore matplotlib datetime plotting functionality. This should
13+
resolve issues for users who relied implicitly on pandas to plot datetimes
14+
with matplotlib. See :ref:`here <whatsnew_0211.special>`.
15+
- Improvements to the Parquet IO functions introduced in 0.21.0. See
16+
:ref:`here <whatsnew_0211.enhancements.parquet>`.
17+
18+
19+
.. contents:: What's new in v0.21.1
20+
:local:
21+
:backlinks: none
22+
923

1024
.. _whatsnew_0211.special:
1125

@@ -42,9 +56,13 @@ registering them when they want them.
4256
New features
4357
~~~~~~~~~~~~
4458

45-
-
46-
-
47-
-
59+
.. _whatsnew_0211.enhancements.parquet:
60+
61+
Improvements to the Parquet IO functionality
62+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63+
64+
- :func:`read_parquet` now allows to specify the columns to read from a parquet file (:issue:`18154`)
65+
- :func:`read_parquet` now allows to specify kwargs which are passed to the respective engine (:issue:`18216`)
4866

4967
.. _whatsnew_0211.enhancements.other:
5068

@@ -54,7 +72,6 @@ Other Enhancements
5472
- :meth:`Timestamp.timestamp` is now available in Python 2.7. (:issue:`17329`)
5573
- :class:`Grouper` and :class:`TimeGrouper` now have a friendly repr output (:issue:`18203`).
5674
- Enabled the use of non-default indexes in :func:`DataFrame.to_parquet` where the underlying engine supports it (:issue:`18581`)
57-
-
5875

5976
.. _whatsnew_0211.deprecations:
6077

@@ -70,24 +87,11 @@ Performance Improvements
7087
~~~~~~~~~~~~~~~~~~~~~~~~
7188

7289
- Improved performance of plotting large series/dataframes (:issue:`18236`).
73-
-
74-
-
75-
76-
.. _whatsnew_0211.docs:
77-
78-
Documentation Changes
79-
~~~~~~~~~~~~~~~~~~~~~
80-
81-
-
82-
-
83-
-
8490

8591
.. _whatsnew_0211.bug_fixes:
8692

8793
Bug Fixes
8894
~~~~~~~~~
89-
-
90-
9195

9296
Conversion
9397
^^^^^^^^^^
@@ -98,7 +102,6 @@ Conversion
98102
- Bug in :func:`DataFrame.to_dict` where columns of datetime that are tz-aware were not converted to required arrays when used with ``orient='records'``, raising``TypeError` (:issue:`18372`)
99103
- Bug in :class:`DateTimeIndex` and :meth:`date_range` where mismatching tz-aware ``start`` and ``end`` timezones would not raise an err if ``end.tzinfo`` is None (:issue:`18431`)
100104
- Bug in :meth:`Series.fillna` which raised when passed a long integer on Python 2 (:issue:`18159`).
101-
-
102105

103106
Indexing
104107
^^^^^^^^
@@ -108,7 +111,6 @@ Indexing
108111
- Bug in :class:`IntervalIndex` constructor when a list of intervals is passed with non-default ``closed`` (:issue:`18334`)
109112
- Bug in ``Index.putmask`` when an invalid mask passed (:issue:`18368`)
110113
- Bug in masked assignment of a ``timedelta64[ns]`` dtype ``Series``, incorrectly coerced to float (:issue:`18493`)
111-
-
112114

113115
I/O
114116
^^^
@@ -118,8 +120,6 @@ I/O
118120
- Bug in :func:`read_csv` for handling null values in index columns when specifying ``na_filter=False`` (:issue:`5239`)
119121
- Bug in :func:`read_csv` when reading numeric category fields with high cardinality (:issue:`18186`)
120122
- Bug in :meth:`DataFrame.to_csv` when the table had ``MultiIndex`` columns, and a list of strings was passed in for ``header`` (:issue:`5539`)
121-
- :func:`read_parquet` now allows to specify the columns to read from a parquet file (:issue:`18154`)
122-
- :func:`read_parquet` now allows to specify kwargs which are passed to the respective engine (:issue:`18216`)
123123
- Bug in parsing integer datetime-like columns with specified format in ``read_sql`` (:issue:`17855`).
124124
- Bug in :meth:`DataFrame.to_msgpack` when serializing data of the numpy.bool_ datatype (:issue:`18390`)
125125
- Bug in :func:`read_json` not decoding when reading line deliminted JSON from S3 (:issue:`17200`)
@@ -130,8 +130,6 @@ Plotting
130130
^^^^^^^^
131131

132132
- Bug in ``DataFrame.plot()`` and ``Series.plot()`` with :class:`DatetimeIndex` where a figure generated by them is not pickleable in Python 3 (:issue:`18439`)
133-
-
134-
-
135133

136134
Groupby/Resample/Rolling
137135
^^^^^^^^^^^^^^^^^^^^^^^^
@@ -140,15 +138,6 @@ Groupby/Resample/Rolling
140138
- Bug in ``DataFrame.resample(...)`` when there is a time change (DST) and resampling frequecy is 12h or higher (:issue:`15549`)
141139
- Bug in ``pd.DataFrameGroupBy.count()`` when counting over a datetimelike column (:issue:`13393`)
142140
- Bug in ``rolling.var`` where calculation is inaccurate with a zero-valued array (:issue:`18430`)
143-
-
144-
-
145-
146-
Sparse
147-
^^^^^^
148-
149-
-
150-
-
151-
-
152141

153142
Reshaping
154143
^^^^^^^^^
@@ -162,9 +151,6 @@ Numeric
162151
^^^^^^^
163152

164153
- Bug in ``pd.Series.rolling.skew()`` and ``rolling.kurt()`` with all equal values has floating issue (:issue:`18044`)
165-
-
166-
-
167-
-
168154

169155
Categorical
170156
^^^^^^^^^^^
@@ -179,9 +165,3 @@ String
179165
^^^^^^
180166

181167
- :meth:`Series.str.split()` will now propogate ``NaN`` values across all expanded columns instead of ``None`` (:issue:`18450`)
182-
183-
Other
184-
^^^^^
185-
186-
-
187-
-

doc/source/whatsnew/v0.22.0.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ Other Enhancements
135135
- Improved wording of ``ValueError`` raised in :func:`read_csv` when the ``usecols`` argument cannot match all columns. (:issue:`17301`)
136136
- :func:`DataFrame.corrwith` now silently drops non-numeric columns when passed a Series. Before, an exception was raised (:issue:`18570`).
137137
- :class:`IntervalIndex` now supports time zone aware ``Interval`` objects (:issue:`18537`, :issue:`18538`)
138-
138+
- :func:`read_excel()` has gained the ``nrows`` parameter (:issue:`16645`)
139+
- :func:``DataFrame.to_json`` and ``Series.to_json`` now accept an ``index`` argument which allows the user to exclude the index from the JSON output (:issue:`17394`)
139140

140141
.. _whatsnew_0220.api_breaking:
141142

@@ -188,6 +189,8 @@ Other API Changes
188189
- :func:`pandas.DataFrame.merge` no longer casts a ``float`` column to ``object`` when merging on ``int`` and ``float`` columns (:issue:`16572`)
189190
- The default NA value for :class:`UInt64Index` has changed from 0 to ``NaN``, which impacts methods that mask with NA, such as ``UInt64Index.where()`` (:issue:`18398`)
190191
- Refactored ``setup.py`` to use ``find_packages`` instead of explicitly listing out all subpackages (:issue:`18535`)
192+
- Rearranged the order of keyword arguments in :func:`read_excel()` to align with :func:`read_csv()` (:pr:`16672`)
193+
- :func:`pandas.merge` now raises a ``ValueError`` when trying to merge on incompatible data types (:issue:`9780`)
191194

192195
.. _whatsnew_0220.deprecations:
193196

@@ -282,7 +285,7 @@ I/O
282285
Plotting
283286
^^^^^^^^
284287

285-
-
288+
- :func: `DataFrame.plot` now raises a ``ValueError`` when the ``x`` or ``y`` argument is improperly formed (:issue:`18671`)
286289
-
287290
-
288291

pandas/_libs/src/datetime/np_datetime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ void pandas_datetime_to_datetimestruct(npy_datetime val, PANDAS_DATETIMEUNIT fr,
527527
void pandas_timedelta_to_timedeltastruct(npy_timedelta val,
528528
PANDAS_DATETIMEUNIT fr,
529529
pandas_timedeltastruct *result) {
530-
convert_timedelta_to_timedeltastruct(fr, val, result);
530+
convert_timedelta_to_timedeltastruct(fr, val, result);
531531
}
532532

533533

pandas/_libs/src/datetime/np_datetime_strings.c

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -33,55 +33,6 @@ This file implements string parsing and creation for NumPy datetime.
3333
#include "np_datetime_strings.h"
3434

3535

36-
/* Platform-specific time_t typedef */
37-
typedef time_t NPY_TIME_T;
38-
39-
/*
40-
* Wraps `localtime` functionality for multiple platforms. This
41-
* converts a time value to a time structure in the local timezone.
42-
*
43-
* Returns 0 on success, -1 on failure.
44-
*/
45-
static int get_localtime(NPY_TIME_T *ts, struct tm *tms) {
46-
char *func_name = "<unknown>";
47-
#if defined(_WIN32)
48-
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
49-
if (localtime_s(tms, ts) != 0) {
50-
func_name = "localtime_s";
51-
goto fail;
52-
}
53-
#elif defined(__GNUC__) && defined(NPY_MINGW_USE_CUSTOM_MSVCR)
54-
if (_localtime64_s(tms, ts) != 0) {
55-
func_name = "_localtime64_s";
56-
goto fail;
57-
}
58-
#else
59-
struct tm *tms_tmp;
60-
localtime_r(ts, tms_tmp);
61-
if (tms_tmp == NULL) {
62-
func_name = "localtime";
63-
goto fail;
64-
}
65-
memcpy(tms, tms_tmp, sizeof(struct tm));
66-
#endif
67-
#else
68-
if (localtime_r(ts, tms) == NULL) {
69-
func_name = "localtime_r";
70-
goto fail;
71-
}
72-
#endif
73-
74-
return 0;
75-
76-
fail:
77-
PyErr_Format(PyExc_OSError,
78-
"Failed to use '%s' to convert "
79-
"to a local time",
80-
func_name);
81-
return -1;
82-
}
83-
84-
8536
/*
8637
* Parses (almost) standard ISO 8601 date strings. The differences are:
8738
*
@@ -138,59 +89,6 @@ int parse_iso_8601_datetime(char *str, int len,
13889
out->month = 1;
13990
out->day = 1;
14091

141-
/*
142-
* The string "today" means take today's date in local time, and
143-
* convert it to a date representation. This date representation, if
144-
* forced into a time unit, will be at midnight UTC.
145-
* This is perhaps a little weird, but done so that the
146-
* 'datetime64[D]' type produces the date you expect, rather than
147-
* switching to an adjacent day depending on the current time and your
148-
* timezone.
149-
*/
150-
if (len == 5 && tolower(str[0]) == 't' && tolower(str[1]) == 'o' &&
151-
tolower(str[2]) == 'd' && tolower(str[3]) == 'a' &&
152-
tolower(str[4]) == 'y') {
153-
NPY_TIME_T rawtime = 0;
154-
struct tm tm_;
155-
156-
time(&rawtime);
157-
if (get_localtime(&rawtime, &tm_) < 0) {
158-
return -1;
159-
}
160-
out->year = tm_.tm_year + 1900;
161-
out->month = tm_.tm_mon + 1;
162-
out->day = tm_.tm_mday;
163-
164-
/*
165-
* Indicate that this was a special value, and
166-
* is a date (unit 'D').
167-
*/
168-
if (out_local != NULL) {
169-
*out_local = 0;
170-
}
171-
172-
return 0;
173-
}
174-
175-
/* The string "now" resolves to the current UTC time */
176-
if (len == 3 && tolower(str[0]) == 'n' && tolower(str[1]) == 'o' &&
177-
tolower(str[2]) == 'w') {
178-
NPY_TIME_T rawtime = 0;
179-
180-
time(&rawtime);
181-
182-
/*
183-
* Indicate that this was a special value, and
184-
* use 's' because the time() function has resolution
185-
* seconds.
186-
*/
187-
if (out_local != NULL) {
188-
*out_local = 0;
189-
}
190-
191-
return convert_datetime_to_datetimestruct(PANDAS_FR_s, rawtime, out);
192-
}
193-
19492
substr = str;
19593
sublen = len;
19694

0 commit comments

Comments
 (0)