Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'Timestamp'

I have ggplot successfully installed in my python 3.6.3 using the code below:

conda install -c conda-forge ggplot 

But when I import it in my notebook using the code below, I get an error:

from ggplot import *
ImportError: cannot import name 'Timestamp'

I would appreciate any idea on how I can solve this problem.

like image 252
Krantz Avatar asked May 29 '18 19:05

Krantz


3 Answers

I have encountered the same problem.

Please go to .../site-packages/ggplot/stats/smoothers.py and change

from pandas.lib import Timestamp

to

from pandas import Timestamp

and save.

like image 101
liaoming999 Avatar answered Nov 05 '22 17:11

liaoming999


@Liaoming999 is correct but adding more changes to resolve this problem:

  1. Open file ../site-packages/ggplot/stats/smoothers.py
  2. Change from pandas.lib import Timestamp to from pandas import Timestamp in line 4
  3. Change pd.tslib.Timestamp to pd.Timestamp in line 14.
  4. Save the file
  5. Open file ../site-packages/ggplot/utils.py and goto line 81 and do the same as step 3. Thanks to @wmsmith for this tip.

p.s.: General advise is to use Anaconda or some Virtual env.

like image 15
Srikar Appalaraju Avatar answered Nov 05 '22 17:11

Srikar Appalaraju


I encountered the same problem after upgrading to pandas 0.23 on a databricks server.

Had to come up with this command-line solution using the unix sed tool:

cd .../python/lib/python3.5/site-packages/ggplot/stats/
sed -i 's/pandas.lib/pandas/g' smoothers.py
like image 5
dportman Avatar answered Nov 05 '22 17:11

dportman