BUG: warning shown when parsing delimited date string even if users … · pandas-dev/pandas@113bdb3 (original) (raw)

`@@ -85,12 +85,6 @@ class DateParseError(ValueError):

`

85

85

`_DEFAULT_DATETIME = datetime(1, 1, 1).replace(hour=0, minute=0,

`

86

86

`second=0, microsecond=0)

`

87

87

``

88

``

`-

PARSING_WARNING_MSG = (

`

89

``

`-

"Parsing dates in {format} format when dayfirst={dayfirst} was specified. "

`

90

``

`-

"This may lead to inconsistently parsed dates! Specify a format "

`

91

``

`-

"to ensure consistent parsing."

`

92

``

`-

)

`

93

``

-

94

88

`cdef:

`

95

89

`set _not_datelike_strings = {"a", "A", "m", "M", "p", "P", "t", "T"}

`

96

90

``

`@@ -203,28 +197,10 @@ cdef object _parse_delimited_date(str date_string, bint dayfirst):

`

203

197

`# date_string can't be converted to date, above format

`

204

198

`return None, None

`

205

199

``

206

``

`-

swapped_day_and_month = False

`

207

200

`if 1 <= month <= MAX_DAYS_IN_MONTH and 1 <= day <= MAX_DAYS_IN_MONTH \

`

208

201

`and (month <= MAX_MONTH or day <= MAX_MONTH):

`

209

202

`if (month > MAX_MONTH or (day <= MAX_MONTH and dayfirst)) and can_swap:

`

210

203

` day, month = month, day

`

211

``

`-

swapped_day_and_month = True

`

212

``

`-

if dayfirst and not swapped_day_and_month:

`

213

``

`-

warnings.warn(

`

214

``

`-

PARSING_WARNING_MSG.format(

`

215

``

`-

format="MM/DD/YYYY",

`

216

``

`-

dayfirst="True",

`

217

``

`-

),

`

218

``

`-

stacklevel=find_stack_level(),

`

219

``

`-

)

`

220

``

`-

elif not dayfirst and swapped_day_and_month:

`

221

``

`-

warnings.warn(

`

222

``

`-

PARSING_WARNING_MSG.format(

`

223

``

`-

format="DD/MM/YYYY",

`

224

``

`-

dayfirst="False (the default)",

`

225

``

`-

),

`

226

``

`-

stacklevel=find_stack_level(),

`

227

``

`-

)

`

228

204

`# In Python <= 3.6.0 there is no range checking for invalid dates

`

229

205

`# in C api, thus we call faster C version for 3.6.1 or newer

`

230

206

`return datetime_new(year, month, day, 0, 0, 0, 0, None), reso

`