8000 ERR: Boolean comparisons of a Series vs None will now be equivalent to null comparisons by jreback · Pull Request #10569 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

ERR: Boolean comparisons of a Series vs None will now be equivalent to null comparisons #10569

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 8 commits into from
Jul 17, 2015
Prev Previous commit
Next Next commit
TST: fixes stata datetimelike comparisons for #10606
  • Loading branch information
jreback committed Jul 17, 2015
commit 4def8e48d9aaa645b2a20a93ba0ad43417024ca1
10 changes: 10 additions & 0 deletions pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2553,6 +2553,16 @@ def is_datetimelike_v_numeric(a, b):
return (needs_i8_conversion(a) and f(b)) or (
needs_i8_conversion(b) and f(a))

def is_datetimelike_v_object(a, b):
# return if we have an i8 convertible and object comparision
if not hasattr(a,'dtype'):
a 10000 = np.asarray(a)
if not hasattr(b, 'dtype'):
b = np.asarray(b)
f = lambda x: is_object_dtype(x)
return (needs_i8_conversion(a) and f(b)) or (
needs_i8_conversion(b) and f(a))

needs_i8_conversion = is_datetime_or_timedelta_dtype

def i8_boxer(arr_or_dtype):
Expand Down
2 changes: 0 additions & 2 deletions pandas/io/tests/test_stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,6 @@ def test_read_chunks_117(self):
self.dta16_117, self.dta17_117, self.dta18_117,
self.dta19_117, self.dta20_117]

raise nose.SkipTest("buggy test: #10606")
for fname in files_117:
for chunksize in 1,2:
for convert_categoricals in False, True:
Expand Down Expand Up @@ -962,7 +961,6 @@ def test_read_chunks_115(self):
self.dta17_115, self.dta18_115, self.dta19_115,
self.dta20_115]

raise nose.SkipTest("buggy test: #10606")
for fname in files_115:
for chunksize in 1,2:
for convert_categoricals in False, True:
Expand Down
11 changes: 6 additions & 5 deletions pandas/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
from numpy.testing import assert_array_equal

import pandas as pd
from pandas.core.common import is_sequence, array_equivalent, is_list_like, is_number, is_datetimelike_v_numeric
from pandas.core.common import (is_sequence, array_equivalent, is_list_like, is_number,
is_datetimelike_v_numeric, is_datetimelike_v_object)
import pandas.compat as compat
from pandas.compat import(
filter, map, zip, range, unichr, lrange, lmap, lzip, u, callable, Counter,
Expand Down Expand Up @@ -688,10 +689,10 @@ def assert_series_equal(left, right, check_dtype=True,
elif check_datetimelike_compat:
# we want to check only if we have compat dtypes
# e.g. integer and M|m are NOT compat, but we can simply check the values in that case
if is_datetimelike_v_numeric(left, right):
# datetime.datetime and pandas.tslib.Timestamp may hold
# equivalent values but fail assert_frame_equal
if not all([x == y for x, y in zip(left, right)]):
if is_datetimelike_v_numeric(left, right) or is_datetimelike_v_object(left, right):

# datetimelike may have different objects (e.g. datetime.datetime vs Timestamp) but will compare equal
if not Index(left.values).equals(Index(right.values)):
raise AssertionError(
'[datetimelike_compat=True] {0} is not equal to {1}.'.format(left.values,
right.values))
Expand Down
0