Skip to content

Commit

Permalink
Merge pull request #417 from datacamp/import-pandas-when-used
Browse files Browse the repository at this point in the history
[CP-3513] feat: lazy import pandas
  • Loading branch information
rikbw authored Nov 27, 2024
2 parents f2280ff + d0d0025 commit 73efcb4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pythonwhat/Test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import re
import numpy as np
import pandas as pd
from pandas.testing import assert_frame_equal, assert_series_equal
from pythonwhat.tasks import *
from protowhat.Test import Test

Expand Down Expand Up @@ -111,6 +109,8 @@ def areinstance(x, y, tuple_of_classes):
# First try to the faster equality functions. If these don't pass,
# Run the assertions that are typically slower.
def is_equal(x, y):
import pandas as pd
from pandas.testing import assert_frame_equal, assert_series_equal
try:
if areinstance(x, y, (Exception,)):
# Types of errors don't matter (this is debatable)
Expand Down
2 changes: 1 addition & 1 deletion pythonwhat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "2.25.0"
__version__ = "2.26.0"

from .test_exercise import test_exercise, allow_errors
2 changes: 1 addition & 1 deletion pythonwhat/checks/check_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
)
from pythonwhat.checks.check_funcs import part_to_child
from pythonwhat.utils import v2_only
import pandas as pd
import ast


Expand Down Expand Up @@ -289,6 +288,7 @@ def check_df(state, index, missing_msg=None, not_instance_msg=None, expand_msg=N
my_df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6], "c": [7, 8, 9]})
"""
import pandas as pd
child = check_object(
state,
index,
Expand Down

0 comments on commit 73efcb4

Please sign in to comment.