簡體   English   中英

模塊“熊貓”沒有屬性“tslib”

[英]module 'pandas' has no attribute 'tslib'

我無法在 python 中使用ggplot package。

import pandas as pd

from ggplot import *


import pandas as pd

from ggplot import *

它返回:

AttributeError:模塊“熊貓”沒有屬性“tslib”

我在 PC 上的ggplot源文件中更改了pandas模塊的import命令,它對我有用。 您可以在錯誤消息中找到您 PC 上的位置。 對我來說它是C:\Users\user\Anaconda3\Lib\site-packages\ggplot
我更改的文件:
C:\Users\user\Anaconda3\Lib\site-packages\ggplot\utils.py

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

至:

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

C:\Users\user\Anaconda3\Lib\site-packages\ggplot\stats\smoothers.py中進行與上述相同的更改,此外:

from pandas.lib import Timestamp

至:

from pandas import Timestamp
date_types = (
    pd.tslib.Timestamp,
    pd.DatetimeIndex,
    pd.Period,
    pd.PeriodIndex,
    datetime.datetime,
    datetime.time
)

至:

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

你要

 import rpy2

其中有一個問題,但至少你會得到它的工作


我的建議是 go 和 ggplot2 直接在 R 中。 即使正確安裝了 pandas 並且語法並不簡單,也很難讓它工作

我在 colab 中發現了這個問題。 要解決此問題,只需單擊錯誤通知中指向 util.py,smoother.py 的鏈接。

  1. 修復 util.py 中的一些配置:pd.tslib.Timestamp --> pd.Timestamp

然后 ctrl-s 保存新配置

  1. 修復 smoothers.py 中的一些配置: from pandas.lib import Timestamp --> from pandas import Timestamp

然后 ctrl-s 在修復上述所有內容后保存新配置。 再次運行此單元格。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM