Why am I getting the error message name 'datestr' is not defined? Python 2.7
Question: So datestr() is supposed to convert a number into a date. But I keep getting
this Name error message. Am I not loading the correct module. I have searched
the Matplotlib documenation but do not see any specific module that must be
imported.

    
    
    import matplotlib.pyplot as plt
        from matplotlib.dates import DateFormatter, WeekdayLocator,\
            DayLocator, MONDAY
        from matplotlib.finance import quotes_historical_yahoo_ohlc, candlestick_ohlc
        import pandas as pd
        import datetime
        import pandas.io.data as web
        from datetime import date
        import matplotlib
    
        date = 731613
    
        print datestr(date)
        #NameError: name 'datestr' is not defined
    


Answer: It looks like you want the function `mathplotlib.dates.num2date()`. From there
you can convert to a string with `str()` or `strftime()`:

    
    
    >>> from matplotlib.dates import num2date
    >>> num2date(731613)
    datetime.datetime(2004, 2, 2, 0, 0, tzinfo=<matplotlib.dates._UTC object at 0x7f64861fa5d0>)
    >>> print(num2date(731613))
    2004-02-02 00:00:00+00:00
    >>> str(num2date(731613))
    '2004-02-02 00:00:00+00:00'
    

