-
-
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
BUGFIX - AttributeError raised in StataReader.value_labels() #19510
Conversation
Codecov Report
@@ Coverage Diff @@
## master #19510 +/- ##
=======================================
Coverage 91.6% 91.6%
=======================================
Files 150 150
Lines 48750 48750
=======================================
Hits 44657 44657
Misses 4093 4093
Continue to review full report at Codecov.
|
doc/source/whatsnew/v0.23.0.txt
Outdated
@@ -530,6 +530,8 @@ I/O | |||
- Bug in :func:`DataFrame.to_parquet` where an exception was raised if the write destination is S3 (:issue:`19134`) | |||
- :class:`Interval` now supported in :func:`DataFrame.to_excel` for all Excel file types (:issue:`19242`) | |||
- :class:`Timedelta` now supported in :func:`DataFrame.to_excel` for xls file type (:issue:`19242`, :issue:`9155`) | |||
- Bug in :class:`pandas.io.stata.StataReader` raising ``AttributeError`` when ``value_labels()`` called with very old files. Now returns an empty dict (:issue:`19417`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have an entry for StataReader
in the API docs, but we do have StataReader.value_labels
. So could you reword this as
- Bug in :meth:`pandas.io.stata.StataReader.value_labels` raising an ``AttributeError`` when called on very old files. Now returns an empty dict (:issue:`19417`)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
# Test that value_labels() returns an empty dict if the file format | ||
# predates supporting value labels. | ||
dpath = os.path.join(self.dirpath, 'S4_EDUC1.dta') | ||
reader = StataReader(dpath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to close the reader (or do this in a context manager) see other tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
close()
d
if self.format_version <= 108: | ||
# Value labels are not supported in version 108 and earlier. | ||
self._value_labels_read = True | ||
self.value_label_dict = dict() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a preference stated recently to use {}
rather than dict()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah can use {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dict()
is internally consistent with the function.
lgtm. rebasing, ping when green. |
thanks! |
git diff upstream/master -u -- "*.py" | flake8 --diff
Returns empty dict instead of raising AttributeError for very old Stata files. Includes test against very old Stata file.