Home>

The difference between one date value and another date value was taken
There is a column.
The contents are as follows. (There are many missing values, but)
3 NaT
5 NaT
8 NaT
9 NaT
18 NaT
...
8534 27 days 18:46:31
8535 NaT
8547 NaT
8548 156 days 07:19:25
8555 NaT

Extract only date values ​​(for example, 156 of 8548),
We want to delete other data.

So split (), days (), str.split () etc.
I tried it,
Neither series has that attribute
It was played because of that.

I tried reading the official series documentation, but
There wasn't much pinning.

Are there any good ways?

Error message
-------------------------------------------- -------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-40-47464bdb491a>in<module>
      2 Y = df ['First contact (click time)']
      3 sub = X-Y
---->4 sub = pd.to_timedelta (sub, errors = 'coerce'). Days
      5 df ['First Time ~ Check-in'] = sub
      6 print (df ['First time ~ Check-in'])
c: \ users \ 01037485 \ taishi \ lib \ site-packages \ pandas \ core \ generic.py in __getattr __ (self, name)
   5177 if self._info_axis._can_hold_identifiers_and_holds_name (name):
   5178 return self [name]
->5179 return object .__ getattribute __ (self, name)
   5180
   5181 def __setattr __ (self, name, value):
AttributeError: 'Series' object has no attribute 'days'
Applicable source code
X = df ['Check-in date']
Y = df ['First contact (click time)']
sub = X-Y
sub = pd.to_timedelta (sub, errors = 'coerce'). days
df ['first time ~ check-in'] = sub
print (df ['first time ~ check-in'])