No module named 'pandas.lib'

使用ggplot 报错如下信息

ModuleNotFoundError Traceback (most recent call last) in 1 get_ipython().run_line_magic('matplotlib', 'inline') 2 import pandas as pd ----> 3 import ggplot 4 meat_lng= pd.melt(melt[['data','beef','pork','broilers']],id_vars='data') 5 ggplot(aes(x= 'data', y= 'value', colour = 'variable'), data = meat_lng) + geom_point(color = 'red') ~\AppData\Local\Continuum\anaconda3\lib\site-packages\ggplot\__init__.py in 18 19 from .geoms import geom_area, geom_blank, geom_boxplot, geom_line, geom_point, geom_jitter, geom_histogram, geom_density, geom_hline, geom_vline, geom_bar, geom_abline, geom_tile, geom_rect, geom_bin2d, geom_step, geom_text, geom_path, geom_ribbon, geom_now_its_art, geom_violin, geom_errorbar, geom_polygon ---> 20 from .stats import stat_smooth, stat_density 21 22 from .facets import facet_wrap, facet_grid, Facet ~\AppData\Local\Continuum\anaconda3\lib\site-packages\ggplot\stats\__init__.py in 1 from .stat_density import stat_density ----> 2 from .stat_smooth import stat_smooth ~\AppData\Local\Continuum\anaconda3\lib\site-packages\ggplot\stats\stat_smooth.py in 3 4 from ..geoms.geom import geom ----> 5 from . import smoothers 6 from ..utils import is_date 7 ~\AppData\Local\Continuum\anaconda3\lib\site-packages\ggplot\stats\smoothers.py in 2 unicode_literals) 3 import numpy as np ----> 4 from pandas.lib import Timestamp 5 import pandas as pd 6 import statsmodels.api as sm ModuleNotFoundError: No module named 'pandas.lib'

找了好一圈,以下方法可行

1. 修改C:\Users\nicolas\AppData\Local\Continuum\anaconda3\Lib\site-packages\ggplot\stats\smoothers.py

#from pandas.lib import Timestamp

date_types = (
    pd.Timestamp,
    pd.DatetimeIndex,
    pd.Period,
    pd.PeriodIndex,
    datetime.datetime,
    datetime.time

)
2. 修改C:\Users\nicolas\AppData\Local\Continuum\anaconda3\Lib\site-packages\ggplot\utils.py

date_types = (
    pd._tslib.Timestamp,
    pd.DatetimeIndex,
    pd.Period,
    pd.PeriodIndex,
    datetime.datetime,
    datetime.time
)
 

OK!

 

你可能感兴趣的:(python,ggplot,可视化)