-
-
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
sets data index if it's not None #16422
Conversation
Can you add a test for this? |
There is already some functionality to do this in the |
Actually, have a look at this: https://github.com/pandas-dev/pandas/blob/master/pandas/io/stata.py#L1465-L1466 |
Tests can go in |
I'm on it. |
Codecov Report
@@ Coverage Diff @@
## master #16422 +/- ##
==========================================
- Coverage 90.42% 90.42% -0.01%
==========================================
Files 161 161
Lines 51023 51025 +2
==========================================
Hits 46138 46138
- Misses 4885 4887 +2
Continue to review full report at Codecov.
|
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.
pls add the test from the issue & a whatsnew note.
I am trying to create a test in test_strata before another pull request. I will do that tomorrow morning.
Mo
…Sent from my iPhone
On May 22, 2017, at 5:34 PM, Jeff Reback ***@***.***> wrote:
@jreback requested changes on this pull request.
pls add the test from the issue & a whatsnew note.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I looked at https://docs.google.com/spreadsheets/d/13Xdux8j966QK6QKQtQIyyuS-dOriJvf6uH8LoZyvwYQ/edit#gid=1307138735 How does this help testing? I'm new to this code; please give me some idea how to test it. I was looking at test_stata.py and am confused about why "index" doesn't work anyway. Here are my changes: def read_stata(filepath_or_buffer, convert_dates=True,
- convert_categoricals=True, encoding=None, index=None,
+ convert_categoricals=True, encoding=None, index_col=None,
convert_missing=False, preserve_dtypes=True, columns=None,
order_categoricals=True, chunksize=None, iterator=False):
reader = StataReader(filepath_or_buffer,
convert_dates=convert_dates,
convert_categoricals=convert_categoricals,
- index=index, convert_missing=convert_missing,
+ index=index_col, convert_missing=convert_missing,
preserve_dtypes=preserve_dtypes,
columns=columns,
order_categoricals=order_categoricals,
@@ -178,8 +178,8 @@ def read_stata(filepath_or_buffer, convert_dates=True,
data = reader.read()
finally:
reader.close()
- if index is not None:
- data.set_index(index)
+ if index_col is not None:
+ data.set_index(index_col)
return data |
@mogillies I'll push a test to this branch in a few minutes. |
@mogillies ok just pushed a test. You can run it with |
I wrote this in test_stata.py and passed the test: |
in my branch. |
That test doesn't quite do what we want. We want the user to be able to just do pd.read_stata(path, index_col="my_index" In your test your |
So I am ready to commit and the test passed; but realize if someone call E AttributeError: 'StataReader' object has no attribute 'set_index' Would you like me to commit and PR and is there an issue raised already? |
@mogillies You will have to try to fix that error here as well in this PR, as this is related to your current fix. Repeating what I linked to above: I think you should take a look at https://github.com/pandas-dev/pandas/blob/master/pandas/io/stata.py#L1465-L1466. There in the read function, the |
can you rebase and update? |
closing as stale |
Fixed Bug #16342 read_stata ignores
index
parameter