Skip to content

FIX: Workaround for integer hashing #8982

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 1 commit into from
Dec 6, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,10 @@ class StataMissingValue(StringMixin):
MISSING_VALUES = {}
bases = (101, 32741, 2147483621)
for b in bases:
MISSING_VALUES[b] = '.'
# Conversion to long to avoid hash issues on 32 bit platforms #8968
MISSING_VALUES[compat.long(b)] = '.'
for i in range(1, 27):
MISSING_VALUES[i + b] = '.' + chr(96 + i)
MISSING_VALUES[compat.long(i + b)] = '.' + chr(96 + i)

float32_base = b'\x00\x00\x00\x7f'
increment = struct.unpack('<i', b'\x00\x08\x00\x00')[0]
Expand Down Expand Up @@ -643,6 +644,8 @@ class StataMissingValue(StringMixin):

def __init__(self, value):
self._value = value
# Conversion to long to avoid hash issues on 32 bit platforms #8968
value = compat.long(value) if value < 2147483648 else float(value)
self._str = self.MISSING_VALUES[value]

string = property(lambda self: self._str,
Expand Down Expand Up @@ -1375,13 +1378,6 @@ def _pad_bytes(name, length):
return name + "\x00" * (length - len(name))


def _default_names(nvar):
"""
Returns default Stata names v1, v2, ... vnvar
"""
return ["v%d" % i for i in range(1, nvar+1)]


def _convert_datetime_to_stata_type(fmt):
"""
Converts from one of the stata date formats to a type in TYPE_MAP
Expand Down