Skip to content

MAINT: avoid pandas FutureWarning by checking specific condition - #5260

Merged
bashtage merged 1 commit into
statsmodels:masterfrom
jbrockmendel:deprdata
May 1, 2019
Merged

bashtage merged 1 commit into
statsmodels:masterfrom
jbrockmendel:deprdata

Conversation

@jbrockmendel

Copy link
Copy Markdown
Contributor

Noticed in test logs:

iolib/table.py:639: FutureWarning: Index.data is deprecated and will be removed in a future version
  self.data = data.data
iolib/table.py:639: FutureWarning: Float64Index.data is deprecated and will be removed in a future version
  self.data = data.data

Cell.__init__ currently uses a try/except to duck-type the check for another Cell object being passed as data. In the case where a pandas Index is passed, the try/except works correctly, but not before issuing a warning.

This PR changes the try/except check to a specific check for the relevant case, avoiding the FutureWarning.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.002%) to 84.211% when pulling acb46be on jbrockmendel:deprdata into e1d1156 on statsmodels:master.

@codecov

codecov Bot commented Sep 27, 2018

Copy link
Copy Markdown

Codecov Report

Merging #5260 into master will increase coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5260      +/-   ##
==========================================
+ Coverage   81.71%   81.71%   +<.01%     
==========================================
  Files         569      569              
  Lines       89699    89706       +7     
  Branches    10028    10029       +1     
==========================================
+ Hits        73294    73306      +12     
+ Misses      14132    14129       -3     
+ Partials     2273     2271       -2
Impacted Files Coverage Δ
statsmodels/iolib/table.py 80.89% <0%> (-0.71%) ⬇️
statsmodels/regression/mixed_linear_model.py 89.77% <0%> (+0.79%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1d1156...acb46be. Read the comment docs.

@josef-pkt

Copy link
Copy Markdown
Member

where do you see those FutureWarnings? I cannot find any

Add a link to the test log as reference in cases like this.

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

I'm not seeing it in the CI logs either, will look for it locally. For the time being, the blockquote above will have to do.

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

I've confirmed that this warning is not hit in the test suite, leaving a couple of possibilities for where I saw it. I'm not ready to rule out "incredibly specific dream"

There are, however, cases where data is a np.float64 object (which has a data attribute).

Regardless, this remains an improvement.

@jbrockmendel

Copy link
Copy Markdown
Contributor Author

OK, it looks like this is happening downstream in sm2 where MNLogit has been patched to fix wrapping. As part of this, model.endog_names is a pd.Index instead of a just "y", and as a result that gets passed to iolib.summary in result.summary()

@bashtage
bashtage merged commit 7685ced into statsmodels:master May 1, 2019
@josef-pkt josef-pkt added this to the 0.10 milestone May 1, 2019
@jbrockmendel
jbrockmendel deleted the deprdata branch May 2, 2019 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants