<legend id='EqZWU'><style id='EqZWU'><dir id='EqZWU'><q id='EqZWU'></q></dir></style></legend>
    1. <small id='EqZWU'></small><noframes id='EqZWU'>

    2. <tfoot id='EqZWU'></tfoot>
        <bdo id='EqZWU'></bdo><ul id='EqZWU'></ul>

        <i id='EqZWU'><tr id='EqZWU'><dt id='EqZWU'><q id='EqZWU'><span id='EqZWU'><b id='EqZWU'><form id='EqZWU'><ins id='EqZWU'></ins><ul id='EqZWU'></ul><sub id='EqZWU'></sub></form><legend id='EqZWU'></legend><bdo id='EqZWU'><pre id='EqZWU'><center id='EqZWU'></center></pre></bdo></b><th id='EqZWU'></th></span></q></dt></tr></i><div id='EqZWU'><tfoot id='EqZWU'></tfoot><dl id='EqZWU'><fieldset id='EqZWU'></fieldset></dl></div>

        是否为两列之间的所有日期添加行?

        add rows for all dates between two columns?(是否为两列之间的所有日期添加行?)

          <tfoot id='9OvY8'></tfoot>

            <tbody id='9OvY8'></tbody>
          • <bdo id='9OvY8'></bdo><ul id='9OvY8'></ul>
            <i id='9OvY8'><tr id='9OvY8'><dt id='9OvY8'><q id='9OvY8'><span id='9OvY8'><b id='9OvY8'><form id='9OvY8'><ins id='9OvY8'></ins><ul id='9OvY8'></ul><sub id='9OvY8'></sub></form><legend id='9OvY8'></legend><bdo id='9OvY8'><pre id='9OvY8'><center id='9OvY8'></center></pre></bdo></b><th id='9OvY8'></th></span></q></dt></tr></i><div id='9OvY8'><tfoot id='9OvY8'></tfoot><dl id='9OvY8'><fieldset id='9OvY8'></fieldset></dl></div>

            <small id='9OvY8'></small><noframes id='9OvY8'>

              1. <legend id='9OvY8'><style id='9OvY8'><dir id='9OvY8'><q id='9OvY8'></q></dir></style></legend>
                  本文介绍了是否为两列之间的所有日期添加行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在两列之间添加所有日期的行?

                  ID     Initiation_Date  Step    Start_Date   End_Date    Days
                  
                  P-03    29-11-2018        3      2018-11-29  2018-12-10  11.0
                  P-04    29-11-2018        4      2018-12-03  2018-12-07   4.0
                  P-05    29-11-2018        5      2018-12-07  2018-12-07   0.0
                  

                  推荐答案

                  使用:

                  mydata = [{'ID' : '10', 'Entry Date': '10/10/2016', 'Exit Date': '15/10/2016'},
                            {'ID' : '20', 'Entry Date': '10/10/2016', 'Exit Date': '18/10/2016'}]
                  
                  df = pd.DataFrame(mydata)
                  
                  #convert columns to datetimes
                  df[['Entry Date','Exit Date']] = df[['Entry Date','Exit Date']].apply(pd.to_datetime)
                  
                  #repeat index by difference of dates
                  df = df.loc[df.index.repeat((df['Exit Date'] - df['Entry Date']).dt.days + 1)]
                  #add counter duplicated rows to day timedeltas to new column
                  df['Date'] = df['Entry Date'] + pd.to_timedelta(df.groupby(level=0).cumcount(), unit='d')
                  #default RangeIndex
                  df = df.reset_index(drop=True)
                  print (df)
                     Entry Date  Exit Date  ID       Date
                  0  2016-10-10 2016-10-15  10 2016-10-10
                  1  2016-10-10 2016-10-15  10 2016-10-11
                  2  2016-10-10 2016-10-15  10 2016-10-12
                  3  2016-10-10 2016-10-15  10 2016-10-13
                  4  2016-10-10 2016-10-15  10 2016-10-14
                  5  2016-10-10 2016-10-15  10 2016-10-15
                  6  2016-10-10 2016-10-18  20 2016-10-10
                  7  2016-10-10 2016-10-18  20 2016-10-11
                  8  2016-10-10 2016-10-18  20 2016-10-12
                  9  2016-10-10 2016-10-18  20 2016-10-13
                  10 2016-10-10 2016-10-18  20 2016-10-14
                  11 2016-10-10 2016-10-18  20 2016-10-15
                  12 2016-10-10 2016-10-18  20 2016-10-16
                  13 2016-10-10 2016-10-18  20 2016-10-17
                  14 2016-10-10 2016-10-18  20 2016-10-18
                  

                  这篇关于是否为两列之间的所有日期添加行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Is there a way of group by month in Pandas starting at specific day number?( pandas 有从特定日期开始的按月分组的方式吗?)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  • <bdo id='CKXTE'></bdo><ul id='CKXTE'></ul>

                        • <tfoot id='CKXTE'></tfoot>

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

                              <tbody id='CKXTE'></tbody>

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

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