Skip to content

Instantly share code, notes, and snippets.

@jhkennedy
Last active November 9, 2022 07:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhkennedy/e9e7ec353b2a05419e50413368ff0505 to your computer and use it in GitHub Desktop.
Save jhkennedy/e9e7ec353b2a05419e50413368ff0505 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@srinty
Copy link

srinty commented Sep 9, 2022

Hi, Thank you so much for this notebook. I am having an error for, stack.loc[(stack_start <= stack.startTime) & (stack.startTime <= stack_end)]
Can you please tell how to resolve this issue?

Error:
[SpyderKernelApp] ERROR | Error in message handler
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.8/site-packages/ipykernel/kernelbase.py", line 461, in dispatch_queue
await self.process_one()
File "/opt/anaconda3/lib/python3.8/site-packages/ipykernel/kernelbase.py", line 450, in process_one
await dispatch(*args)
TypeError: object NoneType can't be used in 'await' expression
Traceback (most recent call last):

File "/opt/anaconda3/lib/python3.8/site-packages/pandas/core/arrays/datetimelike.py", line 536, in _validate_comparison_value
self._check_compatible_with(other)

File "/opt/anaconda3/lib/python3.8/site-packages/pandas/core/arrays/datetimes.py", line 508, in _check_compatible_with
self._assert_tzawareness_compat(other)

File "/opt/anaconda3/lib/python3.8/site-packages/pandas/core/arrays/datetimes.py", line 715, in _assert_tzawareness_compat
raise TypeError(

TypeError: Cannot compare tz-naive and tz-aware datetime-like objects

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "/opt/anaconda3/lib/python3.8/site-packages/pandas/core/arrays/datetimelike.py", line 1008, in _cmp_method
other = self._validate_comparison_value(other)

File "/opt/anaconda3/lib/python3.8/site-packages/pandas/core/arrays/datetimelike.py", line 539, in _validate_comparison_value
raise InvalidComparison(other) from err

InvalidComparison: 2018-01-01 00:00:00

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/var/folders/5q/5tntqnbn0yzc5gh280ncl2jm0000gn/T/ipykernel_975/1019817884.py", line 1, in
stack = stack.loc[(stack_start <= stack.startTime) & (stack.startTime <= stack_end)]

File "/opt/anaconda3/lib/python3.8/site-packages/pandas/core/ops/common.py", line 70, in new_method
return method(self, other)

File "/opt/anaconda3/lib/python3.8/site-packages/pandas/core/arraylike.py", line 60, in ge
return self._cmp_method(other, operator.ge)

File "/opt/anaconda3/lib/python3.8/site-packages/pandas/core/series.py", line 5620, in _cmp_method
res_values = ops.comparison_op(lvalues, rvalues, op)

File "/opt/anaconda3/lib/python3.8/site-packages/pandas/core/ops/array_ops.py", line 269, in comparison_op
res_values = op(lvalues, rvalues)

File "/opt/anaconda3/lib/python3.8/site-packages/pandas/core/ops/common.py", line 70, in new_method
return method(self, other)

File "/opt/anaconda3/lib/python3.8/site-packages/pandas/core/arraylike.py", line 60, in ge
return self._cmp_method(other, operator.ge)

File "/opt/anaconda3/lib/python3.8/site-packages/pandas/core/arrays/datetimelike.py", line 1010, in _cmp_method
return invalid_comparison(self, other, op)

File "/opt/anaconda3/lib/python3.8/site-packages/pandas/core/ops/invalid.py", line 34, in invalid_comparison
raise TypeError(f"Invalid comparison between dtype={left.dtype} and {typ}")

TypeError: Invalid comparison between dtype=datetime64[ns, tzutc()] and datetime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment