BUG: Set index when reading stata file by bashtage · Pull Request #17328 · pandas-dev/pandas (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation19 Commits1 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

bashtage

gfyoung

@@ -1486,6 +1486,8 @@ def read(self, nrows=None, convert_dates=None,
columns = self._columns
if order_categoricals is None:
order_categoricals = self._order_categoricals
if index is None:
index = self._index

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have tests that hit this path?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in PR

@codecov

@codecov

@codecov

@TomAugspurger

Did we want to change the keyword from index to index_col to match read_csv?

@bashtage

@bashtage

Does this need deprecation?

@bashtage

Last one, is there a pattern to follow for renaming (e.g. a decorator, *kwargs, etc)

@TomAugspurger

Yeah, there's an @deprecate_kwarg decorator somewhere. Honestly not sure about whether it needs a deprecation, since the old one didn't do anything, but we may as well.

@TomAugspurger

It's in pandas/util/_decorators.py btw.

@bashtage

I went ahead and did the insta-deprecate.

jreback

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments. can you deprecate index (and direct to index_col) as well.

@@ -293,6 +293,7 @@ Other API Changes
- :func:`Series.argmin` and :func:`Series.argmax` will now raise a ``TypeError`` when used with ``object`` dtypes, instead of a ``ValueError`` (:issue:`13595`)
- :class:`Period` is now immutable, and will now raise an ``AttributeError`` when a user tries to assign a new value to the ``ordinal`` or ``freq`` attributes (:issue:`17116`).
- :func:`to_datetime` when passed a tz-aware ``origin=`` kwarg will now raise a more informative ``ValueError`` rather than a ``TypeError`` (:issue:`16842`)
- Renamed non-functional `index` to `index_col` in :func:`read_stata` to improve API consistency (:issue:`16342`)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use double backticks here (around index,index_col)

@@ -1309,3 +1309,11 @@ def test_value_labels_iterator(self, write_index):
dta_iter = pd.read_stata(path, iterator=True)
value_labels = dta_iter.value_labels()
assert value_labels == {'A': {0: 'A', 1: 'B', 2: 'C', 3: 'E'}}
def test_set_index(self):
df = tm.makeDataFrame()

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

@bashtage

Ensures index is set when requested during reading of a Stata dta file Deprecates and renames index to index_col for API consistence

closes pandas-dev#16342

@TomAugspurger

minor comments. can you deprecate index (and direct to index_col) as well.

Do we need a deprecation, or can we just "break" API here. index=... didn't work at all earlier, so I'm OK with just changing without a deprecation cycle.

@TomAugspurger

Ahh I see 4e30df8 now so nevermind, that's fine.

@bashtage

@TomAugspurger

alanbato pushed a commit to alanbato/pandas that referenced this pull request

Nov 10, 2017

@bashtage @alanbato

Ensures index is set when requested during reading of a Stata dta file Deprecates and renames index to index_col for API consistence

closes pandas-dev#16342

No-Stream pushed a commit to No-Stream/pandas that referenced this pull request

Nov 28, 2017

@bashtage @No-Stream

Ensures index is set when requested during reading of a Stata dta file Deprecates and renames index to index_col for API consistence

closes pandas-dev#16342