Skip to content

Commit c0aafd7

Browse files
Ajay SaxenaAjay Saxena
Ajay Saxena
authored and
Ajay Saxena
committed
Merge branch 'test_branch'
merging with latest changes from master
2 parents ed1375f + 9946fb7 commit c0aafd7

File tree

14 files changed

+248
-44
lines changed

14 files changed

+248
-44
lines changed

ci/lint.sh

+9-3
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,24 @@ if [ "$LINT" ]; then
1010
# pandas/rpy is deprecated and will be removed.
1111
# pandas/src is C code, so no need to search there.
1212
echo "Linting *.py"
13-
flake8 pandas --filename '*.py' --exclude pandas/rpy,pandas/src
13+
flake8 pandas --filename=*.py --exclude pandas/rpy,pandas/src
14+
if [ $? -ne "0" ]; then
15+
RET=1
16+
fi
1417
echo "Linting *.py DONE"
1518

1619
echo "Linting *.pyx"
17-
flake8 pandas --filename '*.pyx' --select=E501,E302,E203,E111,E114,E221,E303,E128,E231,E126
20+
flake8 pandas --filename=*.pyx --select=E501,E302,E203,E111,E114,E221,E303,E128,E231,E126
21+
if [ $? -ne "0" ]; then
22+
RET=1
23+
fi
1824
echo "Linting *.pyx DONE"
1925

2026
echo "Linting *.pxi.in"
2127
for path in 'src'
2228
do
2329
echo "linting -> pandas/$path"
24-
flake8 pandas/$path --filename '*.pxi.in' --select=E501,E302,E203,E111,E114,E221,E303,E231,E126
30+
flake8 pandas/$path --filename=*.pxi.in --select=E501,E302,E203,E111,E114,E221,E303,E231,E126
2531
if [ $? -ne "0" ]; then
2632
RET=1
2733
fi

ci/requirements-3.5_OSX.pip

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-dateutil>=2.5.0
1+
python-dateutil==2.5.3

doc/source/whatsnew.rst

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ What's New
1818

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

21+
.. include:: whatsnew/v0.19.2.txt
22+
2123
.. include:: whatsnew/v0.19.1.txt
2224

2325
.. include:: whatsnew/v0.19.0.txt

doc/source/whatsnew/v0.19.2.txt

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.. _whatsnew_0192:
2+
3+
v0.19.2 (December ??, 2016)
4+
---------------------------
5+
6+
This is a minor bug-fix release from 0.19.1 and includes some small regression fixes,
7+
bug fixes and performance improvements.
8+
We recommend that all users upgrade to this version.
9+
10+
.. contents:: What's new in v0.19.2
11+
:local:
12+
:backlinks: none
13+
14+
15+
.. _whatsnew_0192.performance:
16+
17+
Performance Improvements
18+
~~~~~~~~~~~~~~~~~~~~~~~~
19+
20+
21+
.. _whatsnew_0192.bug_fixes:
22+
23+
Bug Fixes
24+
~~~~~~~~~
25+
26+
- compat with ``dateutil==2.6.0`` for testing (:issue:`14621`)
27+
- allow ``nanoseconds`` in ``Timestamp.replace`` kwargs (:issue:`14621`)

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ def to_json(self, path_or_buf=None, orient=None, date_format='epoch',
10661066
Handler to call if object cannot otherwise be converted to a
10671067
suitable format for JSON. Should receive a single argument which is
10681068
the object to convert and return a serialisable object.
1069-
lines : boolean, defalut False
1069+
lines : boolean, default False
10701070
If 'orient' is 'records' write out line delimited json format. Will
10711071
throw ValueError if incorrect 'orient' since others are not list
10721072
like.

pandas/core/series.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -1216,16 +1216,10 @@ def count(self, level=None):
12161216
dtype='int64').__finalize__(self)
12171217

12181218
def mode(self):
1219-
"""Returns the mode(s) of the dataset.
1219+
"""Return the mode(s) of the dataset.
12201220
1221-
Empty if nothing occurs at least 2 times. Always returns Series even
1222-
if only one value.
1223-
1224-
Parameters
1225-
----------
1226-
sort : bool, default True
1227-
If True, will lexicographically sort values, if False skips
1228-
sorting. Result ordering when ``sort=False`` is not defined.
1221+
Empty if nothing occurs at least 2 times. Always returns Series even
1222+
if only one value is returned.
12291223
12301224
Returns
12311225
-------

pandas/io/stata.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1210,18 +1210,18 @@ def _read_old_header(self, first_char):
12101210
if tp in self.OLD_TYPE_MAPPING:
12111211
typlist.append(self.OLD_TYPE_MAPPING[tp])
12121212
else:
1213-
typlist.append(tp - 127) # string
1213+
typlist.append(tp - 127) # py2 string, py3 bytes
12141214

12151215
try:
12161216
self.typlist = [self.TYPE_MAP[typ] for typ in typlist]
12171217
except:
12181218
raise ValueError("cannot convert stata types [{0}]"
1219-
.format(','.join(typlist)))
1219+
.format(','.join(str(x) for x in typlist)))
12201220
try:
12211221
self.dtyplist = [self.DTYPE_MAP[typ] for typ in typlist]
12221222
except:
12231223
raise ValueError("cannot convert stata dtypes [{0}]"
1224-
.format(','.join(typlist)))
1224+
.format(','.join(str(x) for x in typlist)))
12251225

12261226
if self.format_version > 108:
12271227
self.varlist = [self._null_terminate(self.path_or_buf.read(33))

pandas/io/tests/test_gbq.py

+3
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,9 @@ def test_upload_data_if_table_exists_append(self):
824824
private_key=_get_private_key_path())
825825

826826
def test_upload_data_if_table_exists_replace(self):
827+
828+
raise nose.SkipTest("buggy test")
829+
827830
destination_table = DESTINATION_TABLE + "4"
828831

829832
test_size = 10

pandas/tests/indexes/test_base.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,19 @@ def test_summary(self):
913913
def test_format(self):
914914
self._check_method_works(Index.format)
915915

916-
index = Index([datetime.now()])
916+
# GH 14626
917+
# our formatting is different by definition when we have
918+
# ms vs us precision (e.g. trailing zeros);
919+
# so don't compare this case
920+
def datetime_now_without_trailing_zeros():
921+
now = datetime.now()
922+
923+
while str(now).endswith("000"):
924+
now = datetime.now()
925+
926+
return now
927+
928+
index = Index([datetime_now_without_trailing_zeros()])
917929

918930
# windows has different precision on datetime.datetime.now (it doesn't
919931
# include us since the default for Timestamp shows these but Index

pandas/tseries/offsets.py

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def wrapper(self, other):
6868
other = other.tz_localize(None)
6969

7070
result = func(self, other)
71+
7172
if self._adjust_dst:
7273
result = tslib._localize_pydatetime(result, tz)
7374

pandas/tseries/tests/test_offsets.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from distutils.version import LooseVersion
23
from datetime import date, datetime, timedelta
34
from dateutil.relativedelta import relativedelta
45
from pandas.compat import range, iteritems
@@ -4851,6 +4852,7 @@ def _test_all_offsets(self, n, **kwds):
48514852

48524853
def _test_offset(self, offset_name, offset_n, tstart, expected_utc_offset):
48534854
offset = DateOffset(**{offset_name: offset_n})
4855+
48544856
t = tstart + offset
48554857
if expected_utc_offset is not None:
48564858
self.assertTrue(get_utc_offset_hours(t) == expected_utc_offset)
@@ -4890,17 +4892,23 @@ def _make_timestamp(self, string, hrs_offset, tz):
48904892
return Timestamp(string + offset_string).tz_convert(tz)
48914893

48924894
def test_fallback_plural(self):
4893-
"""test moving from daylight savings to standard time"""
4895+
# test moving from daylight savings to standard time
4896+
import dateutil
48944897
for tz, utc_offsets in self.timezone_utc_offsets.items():
48954898
hrs_pre = utc_offsets['utc_offset_daylight']
48964899
hrs_post = utc_offsets['utc_offset_standard']
4897-
self._test_all_offsets(
4898-
n=3, tstart=self._make_timestamp(self.ts_pre_fallback,
4899-
hrs_pre, tz),
4900-
expected_utc_offset=hrs_post)
4900+
4901+
if dateutil.__version__ != LooseVersion('2.6.0'):
4902+
# buggy ambiguous behavior in 2.6.0
4903+
# GH 14621
4904+
# https://github.com/dateutil/dateutil/issues/321
4905+
self._test_all_offsets(
4906+
n=3, tstart=self._make_timestamp(self.ts_pre_fallback,
4907+
hrs_pre, tz),
4908+
expected_utc_offset=hrs_post)
49014909

49024910
def test_springforward_plural(self):
4903-
"""test moving from standard to daylight savings"""
4911+
# test moving from standard to daylight savings
49044912
for tz, utc_offsets in self.timezone_utc_offsets.items():
49054913
hrs_pre = utc_offsets['utc_offset_standard']
49064914
hrs_post = utc_offsets['utc_offset_daylight']

pandas/tseries/tests/test_timezones.py

+86-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import numpy as np
66
import pytz
7-
7+
from distutils.version import LooseVersion
88
from pandas.types.dtypes import DatetimeTZDtype
99
from pandas import (Index, Series, DataFrame, isnull, Timestamp)
1010

@@ -518,8 +518,12 @@ def f():
518518

519519
times = date_range("2013-10-26 23:00", "2013-10-27 01:00", freq="H",
520520
tz=tz, ambiguous='infer')
521-
self.assertEqual(times[0], Timestamp('2013-10-26 23:00', tz=tz))
522-
self.assertEqual(times[-1], Timestamp('2013-10-27 01:00', tz=tz))
521+
self.assertEqual(times[0], Timestamp('2013-10-26 23:00', tz=tz,
522+
freq="H"))
523+
if dateutil.__version__ != LooseVersion('2.6.0'):
524+
# GH 14621
525+
self.assertEqual(times[-1], Timestamp('2013-10-27 01:00', tz=tz,
526+
freq="H"))
523527

524528
def test_ambiguous_nat(self):
525529
tz = self.tz('US/Eastern')
@@ -1163,6 +1167,85 @@ class TestTimeZones(tm.TestCase):
11631167
def setUp(self):
11641168
tm._skip_if_no_pytz()
11651169

1170+
def test_replace(self):
1171+
# GH 14621
1172+
# GH 7825
1173+
# replacing datetime components with and w/o presence of a timezone
1174+
dt = Timestamp('2016-01-01 09:00:00')
1175+
result = dt.replace(hour=0)
1176+
expected = Timestamp('2016-01-01 00:00:00')
1177+
self.assertEqual(result, expected)
1178+
1179+
for tz in self.timezones:
1180+
dt = Timestamp('2016-01-01 09:00:00', tz=tz)
1181+
result = dt.replace(hour=0)
1182+
expected = Timestamp('2016-01-01 00:00:00', tz=tz)
1183+
self.assertEqual(result, expected)
1184+
1185+
# we preserve nanoseconds
1186+
dt = Timestamp('2016-01-01 09:00:00.000000123', tz=tz)
1187+
result = dt.replace(hour=0)
1188+
expected = Timestamp('2016-01-01 00:00:00.000000123', tz=tz)
1189+
self.assertEqual(result, expected)
1190+
1191+
# test all
1192+
dt = Timestamp('2016-01-01 09:00:00.000000123', tz=tz)
1193+
result = dt.replace(year=2015, month=2, day=2, hour=0, minute=5,
1194+
second=5, microsecond=5, nanosecond=5)
1195+
expected = Timestamp('2015-02-02 00:05:05.000005005', tz=tz)
1196+
self.assertEqual(result, expected)
1197+
1198+
# error
1199+
def f():
1200+
dt.replace(foo=5)
1201+
self.assertRaises(ValueError, f)
1202+
1203+
def f():
1204+
dt.replace(hour=0.1)
1205+
self.assertRaises(ValueError, f)
1206+
1207+
# assert conversion to naive is the same as replacing tzinfo with None
1208+
dt = Timestamp('2013-11-03 01:59:59.999999-0400', tz='US/Eastern')
1209+
self.assertEqual(dt.tz_localize(None), dt.replace(tzinfo=None))
1210+
1211+
def test_ambiguous_compat(self):
1212+
# validate that pytz and dateutil are compat for dst
1213+
# when the transition happens
1214+
tm._skip_if_no_dateutil()
1215+
tm._skip_if_no_pytz()
1216+
1217+
pytz_zone = 'Europe/London'
1218+
dateutil_zone = 'dateutil/Europe/London'
1219+
result_pytz = (Timestamp('2013-10-27 01:00:00')
1220+
.tz_localize(pytz_zone, ambiguous=0))
1221+
result_dateutil = (Timestamp('2013-10-27 01:00:00')
1222+
.tz_localize(dateutil_zone, ambiguous=0))
1223+
self.assertEqual(result_pytz.value, result_dateutil.value)
1224+
self.assertEqual(result_pytz.value, 1382835600000000000)
1225+
1226+
# dateutil 2.6 buggy w.r.t. ambiguous=0
1227+
if dateutil.__version__ != LooseVersion('2.6.0'):
1228+
# GH 14621
1229+
# https://github.com/dateutil/dateutil/issues/321
1230+
self.assertEqual(result_pytz.to_pydatetime().tzname(),
1231+
result_dateutil.to_pydatetime().tzname())
1232+
self.assertEqual(str(result_pytz), str(result_dateutil))
1233+
1234+
# 1 hour difference
1235+
result_pytz = (Timestamp('2013-10-27 01:00:00')
1236+
.tz_localize(pytz_zone, ambiguous=1))
1237+
result_dateutil = (Timestamp('2013-10-27 01:00:00')
1238+
.tz_localize(dateutil_zone, ambiguous=1))
1239+
self.assertEqual(result_pytz.value, result_dateutil.value)
1240+
self.assertEqual(result_pytz.value, 1382832000000000000)
1241+
1242+
# dateutil < 2.6 is buggy w.r.t. ambiguous timezones
1243+
if dateutil.__version__ > LooseVersion('2.5.3'):
1244+
# GH 14621
1245+
self.assertEqual(str(result_pytz), str(result_dateutil))
1246+
self.assertEqual(result_pytz.to_pydatetime().tzname(),
1247+
result_dateutil.to_pydatetime().tzname())
1248+
11661249
def test_index_equals_with_tz(self):
11671250
left = date_range('1/1/2011', periods=100, freq='H', tz='utc')
11681251
right = date_range('1/1/2011', periods=100, freq='H', tz='US/Eastern')

pandas/tseries/tests/test_tslib.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,9 @@ def test_repr(self):
327327

328328
# dateutil zone change (only matters for repr)
329329
import dateutil
330-
if dateutil.__version__ >= LooseVersion(
331-
'2.3') and dateutil.__version__ <= LooseVersion('2.4.0'):
330+
if (dateutil.__version__ >= LooseVersion('2.3') and
331+
(dateutil.__version__ <= LooseVersion('2.4.0') or
332+
dateutil.__version__ >= LooseVersion('2.6.0'))):
332333
timezones = ['UTC', 'Asia/Tokyo', 'US/Eastern',
333334
'dateutil/US/Pacific']
334335
else:

0 commit comments

Comments
 (0)