Skip to content

Commit

Permalink
Fixes for @jbrockmendel review V1
Browse files Browse the repository at this point in the history
  • Loading branch information
MomIsBestFriend committed Nov 22, 2019
1 parent 4ead557 commit 6ad7006
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
12 changes: 6 additions & 6 deletions pandas/_libs/tslibs/c_timestamp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ class NullFrequencyError(ValueError):
def maybe_integer_op_deprecated(obj):
# GH#22535 add/sub of integers and int-arrays is deprecated
if obj.freq is not None:
warnings.warn(f"Addition/subtraction of integers and integer-arrays "
warnings.warn("Addition/subtraction of integers and integer-arrays "
f"to {type(obj).__name__} is deprecated, "
f"will be removed in a future "
f"version. Instead of adding/subtracting `n`, use "
f"`n * self.freq`"
"will be removed in a future "
"version. Instead of adding/subtracting `n`, use "
"`n * self.freq`"
, FutureWarning)


Expand Down Expand Up @@ -369,13 +369,13 @@ cdef class _Timestamp(datetime):

@property
def _repr_base(self) -> str:
return f'{self._date_repr} {self._time_repr}'
return f"{self._date_repr} {self._time_repr}"

@property
def _date_repr(self) -> str:
# Ideal here would be self.strftime("%Y-%m-%d"), but
# the datetime strftime() methods require year >= 1900
return f'{self.year}-{self.month:02d}-{self.day:02d}'
return f"{self.year}-{self.month:02d}-{self.day:02d}"

@property
def _time_repr(self) -> str:
Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/tslibs/parsing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,8 @@ class _timelex:
self.stream = instream
elif getattr(instream, 'read', None) is None:
raise TypeError(
f'Parser must be a string or character stream, not '
f'{instream.__class__.__name__}')
'Parser must be a string or character stream, not '
f'{type(instream).__name__}')
else:
self.stream = instream.read()

Expand Down
10 changes: 5 additions & 5 deletions pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1275,15 +1275,15 @@ cdef object _period_strftime(int64_t value, int freq, object fmt):
if i == 0:
repl = str(quarter)
elif i == 1: # %f, 2-digit year
repl = f'{year % 100:02d}'
repl = f'{(year % 100):02d}'
elif i == 2:
repl = str(year)
elif i == 3:
repl = f'{value % 1_000:03d}'
repl = f'{(value % 1_000):03d}'
elif i == 4:
repl = f'{value % 1_000_000:06d}'
repl = f'{(value % 1_000_000):06d}'
elif i == 5:
repl = f'{value % 1_000_000_000:09d}'
repl = f'{(value % 1_000_000_000):09d}'

result = result.replace(str_extra_fmts[i], repl)

Expand Down Expand Up @@ -2223,7 +2223,7 @@ cdef class _Period:
"""
base, mult = get_freq_code(self.freq)
formatted = period_format(self.ordinal, base)
value = f"{formatted}"
value = str(formatted)
return value

def __setstate__(self, state):
Expand Down
8 changes: 4 additions & 4 deletions pandas/_libs/tslibs/strptime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ def array_strptime(object[:] values, object fmt,
if is_coerce:
iresult[i] = NPY_NAT
continue
raise ValueError(f"time data {repr(val)} does not match "
f"format {repr(fmt)} (match)")
raise ValueError(f"time data '{val}' does not match "
f"format '{fmt}' (match)")
if len(val) != found.end():
if is_coerce:
iresult[i] = NPY_NAT
Expand Down Expand Up @@ -588,8 +588,8 @@ class TimeRE(dict):
else:
return ''
regex = '|'.join(re.escape(stuff) for stuff in to_convert)
regex = f'(?P<{directive}>{regex}'
return f'{regex})'
regex = f'(?P<{directive}>{regex})'
return regex

def pattern(self, format):
"""
Expand Down
3 changes: 2 additions & 1 deletion pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,8 @@ cdef class _Timedelta(timedelta):
return fmt.format(**comp_dict)

def __repr__(self) -> str:
return f"Timedelta('{self._repr_base(format='long')}')"
repr_based = self._repr_base(format='long')
return f"Timedelta('{repr_based}')"

def __str__(self) -> str:
return self._repr_base(format='long')
Expand Down

0 comments on commit 6ad7006

Please sign in to comment.