Skip to content
This repository was archived by the owner on Apr 24, 2020. It is now read-only.

Fix FutureWarning in heavy_tails.rst #787

Closed
wants to merge 1 commit into from
Closed

Conversation

mtiley
Copy link
Collaborator

@mtiley mtiley commented Nov 29, 2019

Relates to issue #776

  • imports and calls register_matplotlib_converters
  • adds comment explanation

@jstac Is this what you're after?

 - imports and calls register_matplotlib_converters
 - adds comment explanation
@jstac
Copy link
Contributor

jstac commented Nov 29, 2019

Thanks @mtiley

Often these future warnings mean "we want you to do things a different way now".

So there might be a solution that's simpler and neater.

(One that comes to mind is that we could strip the pandas objects down into more simple objects like numpy arrays before passing them to plot. But this might not be optimal. I don't know.)

Would you mind to dig a little more? If you can't find a neater solution please let me know.

@mtiley
Copy link
Collaborator Author

mtiley commented Nov 29, 2019

My understanding of the problem is that yfinance.download creates a pandas series which stores time data with a pandas datatype (Timestamp or datetime64). The warning results from non-explicit conversion (using a pandas converter) of the data into a datatype supported by matplotlib (datetime).
pandas-dev/pandas#18301

Pandas no longer wants to automatically register its converters on import (overwriting matplotlib's own datetime plotting, see facebook/prophet#999) since it is intrusive. In the future it will be necessary to explicitly register the converters when they are needed for a matplotlib .plot command.

Because yfinance uses the pandas datatypes and we want to plot with matplotlib I don't see a way around converting them using the pandas converter (explicitly or implicitly with warning). Pandas' own plotting methods work with neither explicit registration of the converters nor a FutureWarning but they aren't the standard in the lectures.

My understanding of this is a bit patchy still, and it seems strange that this should be happening, since matplotlib now supports datetime64 and should handle it fine (without needing pandas converters). Maybe related to how yfinance constructs the series?

Closing this PR - I'll make another one with a neater inclusion of the converter registration in a separate codeblock.

@mtiley
Copy link
Collaborator Author

mtiley commented Nov 29, 2019

Interesting: Pandas folks want explicit registration, someone has a warning issue only with pandas import pandas-dev/pandas#24964

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants