datatable icon indicating copy to clipboard operation
datatable copied to clipboard

[BUG] replace does not work on date columns

Open samukweku opened this issue 4 years ago • 1 comments

  • Did you find a bug in datatable, or maybe the bug found you? The replace function does not work on date columns; no change is effected.

  • How to reproduce the bug?

source = {"dates" : [date(2000, 1, 5), date(2010, 11, 23), date(2020, 2, 29), None],
          "integers" : range(1, 5),
          "floats" : [10.0, 11.5, 12.3, -13],
          "strings" : ['A', 'B', None, 'D']
          }
DT = dt.Frame(source)

DT
   | dates       integers   floats  strings
   | date32         int32  float64  str32  
-- + ----------  --------  -------  -------
 0 | 2000-01-05         1     10    A      
 1 | 2010-11-23         2     11.5  B      
 2 | 2020-02-29         3     12.3  NA     
 3 | NA                 4    -13    D      
[4 rows x 4 columns]

DT.replace(date(2000, 1, 5), date(2999, 12, 31))

DT
   | dates       integers   floats  strings
   | date32         int32  float64  str32  
-- + ----------  --------  -------  -------
 0 | 2000-01-05         1     10    A      # the date does not change
 1 | 2010-11-23         2     11.5  B      
 2 | 2020-02-29         3     12.3  NA     
 3 | NA                 4    -13    D      
  • What was the expected behavior?
DT
   | dates       integers   floats  strings
   | date32         int32  float64  str32  
-- + ----------  --------  -------  -------
 0 | 2999-12-31         1     10    A      # expected change
 1 | 2010-11-23         2     11.5  B      
 2 | 2020-02-29         3     12.3  NA     
 3 | NA                 4    -13    D   
  • Your environment? datatable version 1.1 python version 3.9 Linux

samukweku avatar Sep 19 '21 01:09 samukweku

The MRE is

from datatable import dt
from datetime import date as d

DT = dt.Frame([d(2000, 1, 1)])
DT.replace({d(2000, 1, 1) : d(2222, 1, 1)})
print(DT)

produces

   | C0        
   | date32    
-- + ----------
 0 | 2000-01-01
[1 row x 1 column]

should be

   | C0        
   | date32    
-- + ----------
 0 | 2222-01-01
[1 row x 1 column]

oleksiyskononenko avatar Sep 19 '21 07:09 oleksiyskononenko