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

<tfoot id='YcGnA'></tfoot>

      <bdo id='YcGnA'></bdo><ul id='YcGnA'></ul>

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

    2. 如何使用帶有 Pandas 的時間戳按小時對數據幀進行

      How to group dataframe by hour using timestamp with Pandas(如何使用帶有 Pandas 的時間戳按小時對數據幀進行分組)

          <tbody id='3pNPa'></tbody>

            <tfoot id='3pNPa'></tfoot>
            <i id='3pNPa'><tr id='3pNPa'><dt id='3pNPa'><q id='3pNPa'><span id='3pNPa'><b id='3pNPa'><form id='3pNPa'><ins id='3pNPa'></ins><ul id='3pNPa'></ul><sub id='3pNPa'></sub></form><legend id='3pNPa'></legend><bdo id='3pNPa'><pre id='3pNPa'><center id='3pNPa'></center></pre></bdo></b><th id='3pNPa'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='3pNPa'><tfoot id='3pNPa'></tfoot><dl id='3pNPa'><fieldset id='3pNPa'></fieldset></dl></div>
          • <legend id='3pNPa'><style id='3pNPa'><dir id='3pNPa'><q id='3pNPa'></q></dir></style></legend>
              • <bdo id='3pNPa'></bdo><ul id='3pNPa'></ul>

                <small id='3pNPa'></small><noframes id='3pNPa'>

                本文介紹了如何使用帶有 Pandas 的時間戳按小時對數據幀進行分組的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我有以下使用時間戳索引的數據幀結構:

                I have the following dataframe structure that is indexed with a timestamp:

                    neg neu norm    pol pos date
                time                        
                1520353341  0.000   1.000   0.0000  0.000000    0.000   
                1520353342  0.121   0.879   -0.2960 0.347851    0.000   
                1520353342  0.217   0.783   -0.6124 0.465833    0.000   
                

                我根據時間戳創建一個日期:

                I create a date from the timestamp:

                data_frame['date'] = [datetime.datetime.fromtimestamp(d) for d in data_frame.time]
                

                結果:

                    neg neu norm    pol pos date
                time                        
                1520353341  0.000   1.000   0.0000  0.000000    0.000   2018-03-06 10:22:21
                1520353342  0.121   0.879   -0.2960 0.347851    0.000   2018-03-06 10:22:22
                1520353342  0.217   0.783   -0.6124 0.465833    0.000   2018-03-06 10:22:22
                

                我想按小時分組,同時獲得除時間戳以外的所有值的平均值,應該是小時小組開始的地方.所以這是我要歸檔的結果:

                I want to group by hour, while getting the mean for all the values, except the timestamp, that should be the hour from where the group started. So this is the result I want to archive:

                    neg neu norm    pol pos
                time                    
                1520352000  0.027989    0.893233    0.122535    0.221079    0.078779
                1520355600  0.028861    0.899321    0.103698    0.209353    0.071811
                

                到目前為止,我得到的最接近的是這個 回答:

                The closest I have gotten so far has been with this answer:

                data = data.groupby(data.date.dt.hour).mean()
                

                結果:

                    neg neu norm    pol pos
                date                    
                0   0.027989    0.893233    0.122535    0.221079    0.078779
                1   0.028861    0.899321    0.103698    0.209353    0.071811
                

                但我不知道如何保留考慮到 grouby 開始時間的時間戳.

                But I cant figure out how to keep the timestamp that takes in account he hour where the grouby started.

                推薦答案

                我遇到了這個 gem,pd.DataFrame.resample,在我發布了按小時計算的解決方案之后.

                I came across this gem, pd.DataFrame.resample, after I posted my round-to-hour solution.

                # Construct example dataframe
                times = pd.date_range('1/1/2018', periods=5, freq='25min')
                values = [4,8,3,4,1]
                df = pd.DataFrame({'val':values}, index=times)
                
                # Resample by hour and calculate medians
                df.resample('H').median()
                

                或者你可以使用 groupbyGrouper 如果您不想將時間作為索引:

                Or you can use groupby with Grouper if you don't want times as index:

                df = pd.DataFrame({'val':values, 'times':times})
                df.groupby(pd.Grouper(level='times', freq='H')).median()
                

                這篇關于如何使用帶有 Pandas 的時間戳按小時對數據幀進行分組的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='i4kqv'><style id='i4kqv'><dir id='i4kqv'><q id='i4kqv'></q></dir></style></legend>
                  <i id='i4kqv'><tr id='i4kqv'><dt id='i4kqv'><q id='i4kqv'><span id='i4kqv'><b id='i4kqv'><form id='i4kqv'><ins id='i4kqv'></ins><ul id='i4kqv'></ul><sub id='i4kqv'></sub></form><legend id='i4kqv'></legend><bdo id='i4kqv'><pre id='i4kqv'><center id='i4kqv'></center></pre></bdo></b><th id='i4kqv'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='i4kqv'><tfoot id='i4kqv'></tfoot><dl id='i4kqv'><fieldset id='i4kqv'></fieldset></dl></div>
                    <tbody id='i4kqv'></tbody>
                  <tfoot id='i4kqv'></tfoot>

                      • <bdo id='i4kqv'></bdo><ul id='i4kqv'></ul>
                        1. <small id='i4kqv'></small><noframes id='i4kqv'>

                        2. 主站蜘蛛池模板: 久久成人免费 | av在线免费观看网站 | 国产精品久久久久久婷婷天堂 | 久久伊人青青草 | www.伊人.com | 久久这里有精品 | 国产日韩一区二区 | 永久免费在线观看 | 久久久久久久久久久久一区二区 | 国产精品久久久久久久久久久久久 | av网址在线| 中文在线一区二区 | 97综合在线 | 日韩一区和二区 | 少妇午夜一级艳片欧美精品 | 四虎精品在线 | 欧美精品一区二区免费 | 国产精品国产三级国产aⅴ原创 | 蜜桃视频在线观看免费视频网站www | 精品欧美一区二区三区 | 5060网一级毛片 | 国产亚洲精品综合一区 | av国产精品毛片一区二区小说 | 精品一区电影 | 99re6在线视频精品免费 | 欧美激情黄色 | 国产精品一区二区三区久久 | 青久草视频 | 国产福利在线 | 欧美理论片在线 | 日韩一区二区三区视频在线播放 | 国产成人小视频 | 青青草这里只有精品 | 2020国产在线| 东方伊人免费在线观看 | 国产精品毛片一区二区在线看 | 少妇无套高潮一二三区 | 老子午夜影院 | 日韩精品中文字幕在线 | 在线亚洲精品 | 国产区在线看 |