python valueerror index_DateTimeIndex.to_period引发许多偏移别名的ValueError异常

In[181]:df.to_period('SMS').groupby('date').sum()---------------------------------------------------------------------------KeyErrorTraceback(most recent call

last)pandas/_libs/tslibs/frequencies.pyxinpandas._libs.tslibs.frequencies._period_str_to_code()KeyError:'SMS-15'Duringhandling of the above exception,another exception occurred:ValueErrorTraceback(most recent call

last)in---->1df.to_period('SMS').groupby('date').sum()~/.virtualenvs/py36/lib/python3.6/site-packages/pandas/core/frame.pyinto_period(self,freq,axis,copy)8350axis=self._get_axis_number(axis)8351ifaxis==0:->8352new_data.set_axis(1,self.index.to_period(freq=freq))8353elifaxis==1:8354new_data.set_axis(0,self.columns.to_period(freq=freq))~/.virtualenvs/py36/lib/python3.6/site-packages/pandas/core/accessor.pyinf(self,*args,**kwargs)91def_create_delegator_method(name):92deff(self,*args,**kwargs):--->93returnself._delegate_method(name,*args,**kwargs)9495f.__name__=name~/.virtualenvs/py36/lib/python3.6/site-packages/pandas/core/indexes/datetimelike.pyin_delegate_method(self,name,*args,**kwargs)811812def_delegate_method(self,name,*args,**kwargs):-->813result=operator.methodcaller(name,*args,**kwargs)(self._data)814ifnamenotinself._raw_methods:815result=Index(result,name=self.name)~/.virtualenvs/py36/lib/python3.6/site-packages/pandas/core/arrays/datetimes.pyinto_period(self,freq)1280freq=get_period_alias(freq)1281->1282returnPeriodArray._from_datetime64(self._data,freq,tz=self.tz)12831284defto_perioddelta(self,freq):~/.virtualenvs/py36/lib/python3.6/site-packages/pandas/core/arrays/period.pyin_from_datetime64(cls,data,freq,tz)273PeriodArray[freq]274"""

--> 275 data, freq = dt64arr_to_periodarr(data, freq, tz)

276 return cls(data, freq=freq)

277

~/.virtualenvs/py36/lib/python3.6/site-packages/pandas/core/arrays/period.py

in dt64arr_to_periodarr(data, freq, tz)

914 data = data._values

915

--> 916 base, mult = libfrequencies.get_freq_code(freq)

917 return libperiod.dt64arr_to_periodarr(data.view("i8"), base, tz), freq

918

pandas/_libs/tslibs/frequencies.pyx in

pandas._libs.tslibs.frequencies.get_freq_code()

pandas/_libs/tslibs/frequencies.pyx in

pandas._libs.tslibs.frequencies.get_freq_code()

pandas/_libs/tslibs/frequencies.pyx in

pandas._libs.tslibs.frequencies.get_freq_code()

pandas/_libs/tslibs/frequencies.pyx in

pandas._libs.tslibs.frequencies._period_str_to_code()

ValueError: Invalid frequency: SMS-15

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值