Skip to content

Commit

Permalink
Fix tests using pd.datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankarlos committed Dec 27, 2019
1 parent b45a47d commit 15d6e12
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class TestPDApi(Base):
]
if not compat.PY37:
classes.extend(["Panel", "SparseSeries", "SparseDataFrame"])
deprecated_modules.extend("datetime")
deprecated_modules.append("datetime")

# these are already deprecated; awaiting removal
deprecated_classes: List[str] = []
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/dtypes/test_common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from typing import List

import numpy as np
Expand Down Expand Up @@ -488,7 +489,7 @@ def test_is_numeric_v_string_like():


def test_is_datetimelike_v_numeric():
dt = np.datetime64(pd.datetime(2017, 1, 1))
dt = np.datetime64(datetime(2017, 1, 1))

assert not com.is_datetimelike_v_numeric(1, 1)
assert not com.is_datetimelike_v_numeric(dt, dt)
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/frame/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1146,18 +1146,18 @@ def test_setitem_mixed_datetime(self):
{
"a": [0, 0, 0, 0, 13, 14],
"b": [
pd.datetime(2012, 1, 1),
datetime(2012, 1, 1),
1,
"x",
"y",
pd.datetime(2013, 1, 1),
pd.datetime(2014, 1, 1),
datetime(2013, 1, 1),
datetime(2014, 1, 1),
],
}
)
df = pd.DataFrame(0, columns=list("ab"), index=range(6))
df["b"] = pd.NaT
df.loc[0, "b"] = pd.datetime(2012, 1, 1)
df.loc[0, "b"] = datetime(2012, 1, 1)
df.loc[1, "b"] = 1
df.loc[[2, 3], "b"] = "x", "y"
A = np.array(
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,7 @@ def test_pivot_table_values_key_error():
df = pd.DataFrame(
{
"eventDate": pd.date_range(
pd.datetime.today(), periods=20, freq="M"
datetime.today(), periods=20, freq="M"
).tolist(),
"thename": range(0, 20),
}
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/indexing/test_iloc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" test positional based indexing with iloc """

from datetime import datetime
from warnings import catch_warnings, simplefilter

import numpy as np
Expand Down Expand Up @@ -122,7 +123,7 @@ def check(result, expected):
[
([slice(None), ["A", "D"]]),
(["1", "2"], slice(None)),
([pd.datetime(2019, 1, 1)], slice(None)),
([datetime(2019, 1, 1)], slice(None)),
],
)
def test_iloc_non_integer_raises(self, index, columns, index_vals, column_vals):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/excel/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def test_read_excel_parse_dates(self, ext):
res = pd.read_excel(pth, parse_dates=["date_strings"], index_col=0)
tm.assert_frame_equal(df, res)

date_parser = lambda x: pd.datetime.strptime(x, "%m/%d/%Y")
date_parser = lambda x: datetime.strptime(x, "%m/%d/%Y")
res = pd.read_excel(
pth, parse_dates=["date_strings"], date_parser=date_parser, index_col=0
)
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/io/sas/test_sas7bdat.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
import io
import os
from pathlib import Path
Expand All @@ -23,7 +24,7 @@ def setup_method(self, datapath):
for j in 1, 2:
fname = os.path.join(self.dirpath, f"test_sas7bdat_{j}.csv")
df = pd.read_csv(fname)
epoch = pd.datetime(1960, 1, 1)
epoch = datetime(1960, 1, 1)
t1 = pd.to_timedelta(df["Column4"], unit="d")
df["Column4"] = epoch + t1
t2 = pd.to_timedelta(df["Column12"], unit="d")
Expand Down

0 comments on commit 15d6e12

Please sign in to comment.