Skip to content

Commit 7ac27f7

Browse files
author
Shashwat
committed
added comments for the code
1 parent 359f7dd commit 7ac27f7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/_libs/tslibs/parsing.pyx

+15
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,22 @@ def format_is_iso(f: str) -> bint:
826826
"""
827827
iso_regex = \
828828
r"^\d{4}(-\d{2}(-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?(([+-]\d{2}:\d{2})|Z)?)?)?)?$"
829+
830+
# ^ -> matches the start of the string
831+
# \d{4} -> matches the four digit(0-9) which represent the year
832+
# -\d{2} -> matches the dash followed by 2 digits
833+
# T\d{2}:\d{2}:\d{2} \
834+
-> "T" followed by three groups seperated by colon: represent H:M:S
835+
# (\.\d+)? -> represents the fractions of seconds
836+
# (([+-]\d{2}:\d{2})|Z)? -> optional part match the time zone info
837+
# ? -> The ? at the end makes the part of regex optional
838+
# $ -> matches with the end
839+
829840
excluded_formats = ["%Y%m%d", "%Y%m", "%Y"]
841+
842+
# uses the 're' module to check if the string matches the regular
843+
# expression and not in the list of 'excluded_formats' then it will return true
844+
830845
if re.match(iso_regex, f) and f not in excluded_formats:
831846
return True
832847
return False

0 commit comments

Comments
 (0)