久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<legend id='Ms9F4'><style id='Ms9F4'><dir id='Ms9F4'><q id='Ms9F4'></q></dir></style></legend>

    <tfoot id='Ms9F4'></tfoot>

      • <bdo id='Ms9F4'></bdo><ul id='Ms9F4'></ul>

      <small id='Ms9F4'></small><noframes id='Ms9F4'>

    1. <i id='Ms9F4'><tr id='Ms9F4'><dt id='Ms9F4'><q id='Ms9F4'><span id='Ms9F4'><b id='Ms9F4'><form id='Ms9F4'><ins id='Ms9F4'></ins><ul id='Ms9F4'></ul><sub id='Ms9F4'></sub></form><legend id='Ms9F4'></legend><bdo id='Ms9F4'><pre id='Ms9F4'><center id='Ms9F4'></center></pre></bdo></b><th id='Ms9F4'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Ms9F4'><tfoot id='Ms9F4'></tfoot><dl id='Ms9F4'><fieldset id='Ms9F4'></fieldset></dl></div>

    2. 無法使用 Series 內置函數對時間戳應用方法

      Unable to apply methods on timestamps using Series built-ins(無法使用 Series 內置函數對時間戳應用方法)
    3. <i id='00iJB'><tr id='00iJB'><dt id='00iJB'><q id='00iJB'><span id='00iJB'><b id='00iJB'><form id='00iJB'><ins id='00iJB'></ins><ul id='00iJB'></ul><sub id='00iJB'></sub></form><legend id='00iJB'></legend><bdo id='00iJB'><pre id='00iJB'><center id='00iJB'></center></pre></bdo></b><th id='00iJB'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='00iJB'><tfoot id='00iJB'></tfoot><dl id='00iJB'><fieldset id='00iJB'></fieldset></dl></div>

            <legend id='00iJB'><style id='00iJB'><dir id='00iJB'><q id='00iJB'></q></dir></style></legend>
              <tbody id='00iJB'></tbody>

            <small id='00iJB'></small><noframes id='00iJB'>

                <bdo id='00iJB'></bdo><ul id='00iJB'></ul>
                <tfoot id='00iJB'></tfoot>

                本文介紹了無法使用 Series 內置函數對時間戳應用方法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                關于以下系列:

                0    1411161507178
                1    1411138436009
                2    1411123732180
                3    1411167606146
                4    1411124780140
                5    1411159331327
                6    1411131745474
                7    1411151831454
                8    1411152487758
                9    1411137160544
                Name: my_series, dtype: int64
                

                此命令(轉換為時間戳、本地化并轉換為 EST)有效:

                This command (convert to timestamp, localize and convert to EST) works:

                pd.to_datetime(my_series, unit='ms').apply(lambda x: x.tz_localize('UTC').tz_convert('US/Eastern'))
                

                但是這個失敗了:

                pd.to_datetime(my_series, unit='ms').tz_localize('UTC').tz_convert('US/Eastern')
                

                與:

                TypeError                                 Traceback (most recent call last)
                <ipython-input-3-58187a4b60f8> in <module>()
                ----> 1 lua = pd.to_datetime(df[column], unit='ms').tz_localize('UTC').tz_convert('US/Eastern')
                
                /Users/josh/anaconda/envs/py34/lib/python3.4/site-packages/pandas/core/generic.py in tz_localize(self, tz, axis, copy, infer_dst)
                   3492                 ax_name = self._get_axis_name(axis)
                   3493                 raise TypeError('%s is not a valid DatetimeIndex or PeriodIndex' %
                -> 3494                                 ax_name)
                   3495             else:
                   3496                 ax = DatetimeIndex([],tz=tz)
                
                TypeError: index is not a valid DatetimeIndex or PeriodIndex
                

                這個也是如此:

                my_series.tz_localize('UTC').tz_convert('US/Eastern')
                

                與:

                ---------------------------------------------------------------------------
                TypeError                                 Traceback (most recent call last)
                <ipython-input-4-0a7cb1e94e1e> in <module>()
                ----> 1 lua = df[column].tz_localize('UTC').tz_convert('US/Eastern')
                
                /Users/josh/anaconda/envs/py34/lib/python3.4/site-packages/pandas/core/generic.py in tz_localize(self, tz, axis, copy, infer_dst)
                   3492                 ax_name = self._get_axis_name(axis)
                   3493                 raise TypeError('%s is not a valid DatetimeIndex or PeriodIndex' %
                -> 3494                                 ax_name)
                   3495             else:
                   3496                 ax = DatetimeIndex([],tz=tz)
                
                TypeError: index is not a valid DatetimeIndex or PeriodIndex
                

                據我了解,上面的第二種方法(第一種失敗的方法)應該有效.為什么會失敗?

                As far as I understand, the second approach above (the first one that fails) should work. Why does it fail?

                推薦答案

                tz_localize/tz_convert 作用于對象的 INDEX,而不是值.最簡單的方法是將其轉換為索引,然后進行本地化和轉換.如果你想要一個系列回來,你可以使用 to_series()

                tz_localize/tz_convert act on the INDEX of the object, not on the values. Easiest to simply turn it into an index then localize and convert. If you then want a Series back you can use to_series()

                In [47]: pd.DatetimeIndex(pd.to_datetime(s,unit='ms')).tz_localize('UTC').tz_convert('US/Eastern')
                Out[47]: 
                <class 'pandas.tseries.index.DatetimeIndex'>
                [2014-09-19 17:18:27.178000-04:00, ..., 2014-09-19 10:32:40.544000-04:00]
                Length: 10, Freq: None, Timezone: US/Eastern
                

                這篇關于無法使用 Series 內置函數對時間戳應用方法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個模塊和類)
                Configuring Python to use additional locations for site-packages(配置 Python 以使用站點包的其他位置)
                How to structure python packages without repeating top level name for import(如何在不重復導入頂級名稱的情況下構造python包)
                Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                How to refresh sys.path?(如何刷新 sys.path?)
                Distribute a Python package with a compiled dynamic shared library(分發帶有已編譯動態共享庫的 Python 包)

              • <legend id='MXaEF'><style id='MXaEF'><dir id='MXaEF'><q id='MXaEF'></q></dir></style></legend>

                  <bdo id='MXaEF'></bdo><ul id='MXaEF'></ul>
                    <tbody id='MXaEF'></tbody>

                    <small id='MXaEF'></small><noframes id='MXaEF'>

                      <tfoot id='MXaEF'></tfoot>
                        • <i id='MXaEF'><tr id='MXaEF'><dt id='MXaEF'><q id='MXaEF'><span id='MXaEF'><b id='MXaEF'><form id='MXaEF'><ins id='MXaEF'></ins><ul id='MXaEF'></ul><sub id='MXaEF'></sub></form><legend id='MXaEF'></legend><bdo id='MXaEF'><pre id='MXaEF'><center id='MXaEF'></center></pre></bdo></b><th id='MXaEF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='MXaEF'><tfoot id='MXaEF'></tfoot><dl id='MXaEF'><fieldset id='MXaEF'></fieldset></dl></div>
                          主站蜘蛛池模板: 精品久久久久久久 | 欧美久久一区二区 | 亚洲一区二区三区在线播放 | 国产精品成人69xxx免费视频 | 91久久久精品国产一区二区蜜臀 | 欧美亚洲国产一区二区三区 | av中文字幕在线 | 中文字幕日韩欧美一区二区三区 | 成人精品一区二区 | 日一区二区 | 欧州一区二区三区 | 精品综合久久久 | 久久香蕉精品视频 | 国产中文字幕在线 | 国产情侣在线看 | 国产一区二区三区久久 | av黄色网| 日韩免费视频一区二区 | 中文字幕在线免费 | 9久9久| 黄色网址在线免费观看 | 成人午夜毛片 | 欧美精品一区二区免费 | 在线视频第一页 | 亚洲欧美一区二区三区国产精品 | 精品毛片视频 | 91性高湖久久久久久久久_久久99 | 欧美激情一区二区三区 | 久久久久国产精品www | 亚洲午夜精品一区二区三区他趣 | 午夜一区 | 欧美一区免费 | 人人干天天干 | 午夜精品久久久久99蜜 | 亚洲欧美日韩久久 | 一区视频| 视频在线亚洲 | 久在线观看 | 日韩国产在线 | 久久久久久久97 | 青草福利 |