GithubHelp home page GithubHelp logo

Comments (5)

Weiss-Robin avatar Weiss-Robin commented on April 25, 2024

Had the same issue when using a virtualenv with Python 2.7. Creating a new one with Python 3.5.1 solved the problem for me.

from prophet.

zarak avatar zarak commented on April 25, 2024

Here's my version information and the full traceback:

Ubuntu 16.04.1 LTS
Python 3.5.2 |Anaconda 2.4.1 (64-bit)| (default, Jul 2 2016, 17:53:06)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-a76c855f084a> in <module>()
----> 1 m.fit(df)

/home/z/anaconda3/lib/python3.5/site-packages/fbprophet/forecaster.py in fit(self, df)
    337         history = self.setup_dataframe(history, initialize_scales=True)
    338         self.history = history
--> 339         seasonal_features = self.make_all_seasonality_features(history)
    340 
    341         self.set_changepoints()

/home/z/anaconda3/lib/python3.5/site-packages/fbprophet/forecaster.py in make_all_seasonality_features(self, df)
    286                 365.25,
    287                 10,
--> 288                 'yearly',
    289             ))
    290 

/home/z/anaconda3/lib/python3.5/site-packages/fbprophet/forecaster.py in make_seasonality_features(cls, dates, period, series_order, prefix)
    227     @classmethod
    228     def make_seasonality_features(cls, dates, period, series_order, prefix):
--> 229         features = cls.fourier_series(dates, period, series_order)
    230         columns = [
    231             '{}_{}'.format(prefix, i + 1)

/home/z/anaconda3/lib/python3.5/site-packages/fbprophet/forecaster.py in fourier_series(dates, period, series_order)
    216         t = np.array(
    217             (dates - pd.datetime(1970, 1, 1))
--> 218             .apply(lambda x: x.days)
    219             .astype(np.float)
    220         )

/home/z/anaconda3/lib/python3.5/site-packages/pandas/core/series.py in apply(self, func, convert_dtype, args, **kwds)
   2167             values = lib.map_infer(values, lib.Timestamp)
   2168 
-> 2169         mapped = lib.map_infer(values, f, convert=convert_dtype)
   2170         if len(mapped) and isinstance(mapped[0], Series):
   2171             from pandas.core.frame import DataFrame

pandas/src/inference.pyx in pandas.lib.map_infer (pandas/lib.c:62578)()

/home/z/anaconda3/lib/python3.5/site-packages/fbprophet/forecaster.py in <lambda>(x)
    216         t = np.array(
    217             (dates - pd.datetime(1970, 1, 1))
--> 218             .apply(lambda x: x.days)
    219             .astype(np.float)
    220         )

AttributeError: 'numpy.timedelta64' object has no attribute 'days'

I didn't have any issues running this with conda on OSx.

from prophet.

zarak avatar zarak commented on April 25, 2024

The approaches described in the pandas docs both work for me, but I'm still not sure why it works on my Mac but not on my Linux system.

# to days
In [70]: td / np.timedelta64(1,'D')
Out[70]: 
0    31.000000
1    31.000000
2    31.003507
3          NaN
dtype: float64

In [71]: td.astype('timedelta64[D]')
Out[71]: 
0    31
1    31
2    31
3   NaN
dtype: float64

from prophet.

zarak avatar zarak commented on April 25, 2024

@robin-weiss I think you're right. I upgraded to Anaconda2-4.3.0 and it works fine now. The problem seems to be because of an older version of pandas.

from prophet.

shengbaodong avatar shengbaodong commented on April 25, 2024

I got the same problem on my mac with python2.7.10 + pandas-0.17.1, use pip install -U pandas ; I update my pandas to 0.19.2, and the problem solved

from prophet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.