Skip to content

Commit

Permalink
Merge pull request #2 from hugovk/lazy-pandas
Browse files Browse the repository at this point in the history
Lazily import pandas to speedup non-pandas use
  • Loading branch information
thombashi committed Feb 17, 2023
2 parents 8b6369c + c50adb3 commit b162600
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions tabledata/_core.py
Expand Up @@ -17,14 +17,6 @@
from ._logger import logger


try:
from pandas import DataFrame

INSTALLED_PANDAS = True
except ImportError:
INSTALLED_PANDAS = False


class TableData:
"""
Class to represent a table data structure.
Expand Down Expand Up @@ -428,7 +420,9 @@ def as_dataframe(self) -> "DataFrame":
- `pandas <https://pandas.pydata.org/>`__
"""

if not INSTALLED_PANDAS:
try:
from pandas import DataFrame
except ImportError:
raise RuntimeError("required 'pandas' package to execute as_dataframe method")

dataframe = DataFrame(self.value_matrix)
Expand Down

0 comments on commit b162600

Please sign in to comment.