-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
sas7bdat: Check if the SAS file has zero variables #18184
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
Conversation
Hello @AbdealiJK! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on November 10, 2017 at 03:11 Hours UTC |
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.
can you add a whatsnew note for 0.22 (can be in bug fixes). what did this do before with an empty file?
pandas/tests/io/sas/test_sas7bdat.py
Outdated
@@ -174,3 +176,9 @@ def test_date_time(): | |||
df0 = pd.read_csv(fname, parse_dates=['Date1', 'Date2', 'DateTime', | |||
'DateTimeHi', 'Taiw']) | |||
tm.assert_frame_equal(df, df0) | |||
|
|||
def test_zero_variables(): | |||
dirpath = tm.get_data_path() |
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.
can you add the issue number (if no issue, then this PR number) as a comment
pandas/tests/io/sas/test_sas7bdat.py
Outdated
def test_zero_variables(): | ||
dirpath = tm.get_data_path() | ||
fname = os.path.join(dirpath, "zero_variables.sas7bdat") | ||
with pytest.raises(EmptyDataError): |
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.
can you test with the zero observations file as well (is it the same result)? you can parametrize if that'st the case
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.
The zero observations file gives a None
value while reading an empty the csv file gives an empty dataframe. I think this is a bug but have not fixed it right now
pandas/tests/io/sas/test_sas7bdat.py
Outdated
dirpath = tm.get_data_path() | ||
fname = os.path.join(dirpath, "zero_variables.sas7bdat") | ||
with pytest.raises(EmptyDataError): | ||
df = pd.read_sas(fname) |
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.
don't need the df = here
@jreback - Thanks for the comments. Updated. |
Can you help me with which file I should be updating for this ? |
doc/source/whatsnew/v0.22.0.txt |
@jreback Thanks. its done |
doc/source/whatsnew/v0.22.0.txt
Outdated
@@ -90,6 +90,7 @@ Bug Fixes | |||
- Bug in ``pd.read_msgpack()`` with a non existent file is passed in Python 2 (:issue:`15296`) | |||
- Bug in ``DataFrame.groupby`` where key as tuple in a ``MultiIndex`` were interpreted as a list of keys (:issue:`17979`) | |||
- Bug in :func:`pd.read_csv` where a ``MultiIndex`` with duplicate columns was not being mangled appropriately (:issue:`18062`) | |||
- Bug in :func:`pd.read_sas` where a file with 0 variables gives an invalid error. Now it gives and ``EmptyDataError`` |
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.
what was the previous error? can you re-word this a bit.
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.
Done
If the given SAS file has 0 rows, throw an error for the EmptyData file. When reading, check that the column information is available. If not, throw an error.
Codecov Report
@@ Coverage Diff @@
## master #18184 +/- ##
==========================================
+ Coverage 91.4% 91.41% +0.01%
==========================================
Files 163 163
Lines 50064 50067 +3
==========================================
+ Hits 45759 45767 +8
+ Misses 4305 4300 -5
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18184 +/- ##
==========================================
+ Coverage 91.4% 91.41% +0.01%
==========================================
Files 163 163
Lines 50064 50067 +3
==========================================
+ Hits 45759 45767 +8
+ Misses 4305 4300 -5
Continue to review full report at Codecov.
|
thanks @AbdealiJK |
If the given SAS file has 0 rows, throw an error for the EmptyData file.
When reading, check that the column information is available. If not,
throw an error.
git diff upstream/master -u -- "*.py" | flake8 --diff