Skip to content

Commit

Permalink
Fix backquotes
Browse files Browse the repository at this point in the history
  • Loading branch information
joke1196 committed Jan 30, 2024
1 parent 02513a2 commit d8ba24d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rules/S6884/python/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pd.to_datetime(['2020-10-25 02:00 +0200', '2020-10-25 04:00 +0100']) # mixed tim
# returns Index([2020-10-25 02:00:00+02:00, 2020-10-25 04:00:00+01:00], dtype='object')
----

When processing `datetime`s with mixed offsets, `pandas.to_datetime` will not succeed in creating a
When processing ``datetime``s with mixed offsets, `pandas.to_datetime` will not succeed in creating a
`DatetimeIndex` instead it will create an `Index` of `object`.
Working with dates with different timezones can lead to bugs, for example when comparing these dates.

Expand All @@ -44,7 +44,7 @@ pd.to_datetime(['2018-10-26 12:00 -0530', '2018-10-26 12:00 -0500'], utc=True)
# returns DatetimeIndex(['2018-10-26 17:30:00+00:00', '2018-10-26 17:00:00+00:00'], dtype='datetime64[ns, UTC]', freq=None)
----

If however the intent is to create a `Series` containing `datetime`s with mixed offsets,
If however the intent is to create a `Series` containing ``datetime``s with mixed offsets,
the recommended way would be to use `apply` and `datetime.datetime.strptime`.

== How to fix it
Expand All @@ -61,7 +61,7 @@ import pandas as pd
pd.to_datetime(['2018-10-26 12:00:00']) # Noncompliant: utc defaults to False
pd.to_datetime(['2018-10-26 12:00 -0530', '2018-10-26 12:00 -0500'], utc=False) # Noncompliant: to create a `Series` containing `datetime`s with mixed offsets,
pd.to_datetime(['2018-10-26 12:00 -0530', '2018-10-26 12:00 -0500'], utc=False) # Noncompliant: to create a `Series` containing ``datetime``s with mixed offsets,
# use `apply` and `datetime.datetime.strptime` instead
----

Expand Down

0 comments on commit d8ba24d

Please sign in to comment.