Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazily import pandas to speedup non-pandas use #2

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions tabledata/_core.py
Original file line number Diff line number Diff line change
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