def test_date_format():
x = pd.date_range('1/1/2010', periods=4, freq='4AS')
result = date_format('%Y')(x)
assert result == ['2010', '2014', '2018', '2022']
x = [datetime(year=2005+i, month=i, day=i) for i in range(1, 5)]
result = date_format('%Y:%m:%d')(x)
assert result == \
['2006:01:01', '2007:02:02', '2008:03:03', '2009:04:04']
# Different timezones
pct = pytz.timezone('US/Pacific')
ug = pytz.timezone('Africa/Kampala')
x = [datetime(2010, 1, 1, tzinfo=ug),
datetime(2010, 1, 1, tzinfo=pct)]
with pytest.warns(UserWarning):
date_format()(x)
评论列表
文章目录