-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
value_labels fails to assign value_label_dict, leads to AttributeError #19417
Comments
not really sure what you are suggesting. what exactly are you trying to accomplish here? |
First step is to report the bug. Logistically it seemed smarter to prompt discussion about the issue rather than just attempt a unilateral fix.
I'll happily submit a PR for either of the proposed behavior changes, but as a pandas PR is more than simply a diff to a single .py file I wanted to determine which fix (if any) before putting the PR together. |
@miker985 can you describe the issue a little more clearly? Why does the current implementation cause an issue in user code? |
Right now now my code looks like this reader = pandas.io.stata.StataReader('some file', convert_categoricals=False)
try:
labels_dict = reader.value_labels()
except AttributeError: # stata file too old to contain value labels
labels_dict = {}
# do stuff with labels dict, basically assembling categorical data by hand My specific use case is I am attempting to utilize pandas to load data from a DTA file and then do stuff with the labeled data. I have to set I think that raising an It's also inconsistent. Within |
OK, if you want to make a small test that exercises this, and see if making that change breaks anything then go for it. |
It should just return an empty dictionary since there are none. <=108 is very old Stata and so I suspect that no one who has worked on this recently has any method to create dta files from Stata in a format <=108. |
A little background v113 was the dta file format in Stata 8 which was designed to run on Windows NT & 98. |
Code Sample, a copy-pastable example if possible
Problem description
An unlikely code path will lead to an AttributeError.
Expected Output
I thin it is reasonable to expect
value_labels()
to return eitherNone
or{}
when the stata file'sformat_version
is <= 108Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.1.final.0
python-bits: 64
OS: Darwin
OS-release: 17.3.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.21.0
pytest: 3.0.7
pip: 9.0.1
setuptools: 27.2.0
Cython: None
numpy: 1.13.3
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: