Skip to content

Commit

Permalink
Pandas is required depencies
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Nov 7, 2022
1 parent bcd6cda commit c4a94a2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 27 deletions.
8 changes: 3 additions & 5 deletions holoviews/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from datetime import date, datetime

import pandas as pd

from .boundingregion import * # noqa (API import)
from .data import * # noqa (API import)
from .dimension import * # noqa (API import)
Expand Down Expand Up @@ -29,12 +31,8 @@
Dimension.type_formatters[np.datetime64] = '%Y-%m-%d %H:%M:%S'
Dimension.type_formatters[datetime] = '%Y-%m-%d %H:%M:%S'
Dimension.type_formatters[date] = '%Y-%m-%d'
Dimension.type_formatters[pd.Timestamp] = "%Y-%m-%d %H:%M:%S"

try:
import pandas as pd
Dimension.type_formatters[pd.Timestamp] = "%Y-%m-%d %H:%M:%S"
except ImportError:
pass

def public(obj):
if not isinstance(obj, type): return False
Expand Down
9 changes: 1 addition & 8 deletions holoviews/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1865,12 +1865,7 @@ class ndmapping_groupby(param.ParameterizedFunction):

def __call__(self, ndmapping, dimensions, container_type,
group_type, sort=False, **kwargs):
try:
import pandas # noqa (optional import)
groupby = self.groupby_pandas
except ImportError:
groupby = self.groupby_python
return groupby(ndmapping, dimensions, container_type,
return self.groupby_pandas(ndmapping, dimensions, container_type,
group_type, sort=sort, **kwargs)

@param.parameterized.bothmethod
Expand Down Expand Up @@ -2080,8 +2075,6 @@ def parse_datetime(date):
"""
Parses dates specified as string or integer or pandas Timestamp
"""
if pd is None:
raise ImportError('Parsing dates from strings requires pandas')
return pd.to_datetime(date).to_datetime64()


Expand Down
8 changes: 2 additions & 6 deletions holoviews/element/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@

import param
import numpy as np
import pandas as pd

from ..core import Dataset, OrderedDict
from ..core.boundingregion import BoundingBox
from ..core.data import default_datatype
from ..core.data import default_datatype, PandasInterface
from ..core.operation import Operation
from ..core.sheetcoords import Slice
from ..core.util import (
cartesian_product, datetime_types, is_cyclic, is_nan,
one_to_one, sort_topologically
)

try:
import pandas as pd
from ..core.data import PandasInterface
except ImportError:
pd = None


def split_path(path):
Expand Down
15 changes: 7 additions & 8 deletions holoviews/plotting/mpl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ...core import Layout, Collator, GridMatrix, config
from ...core.options import Cycle, Palette, Options
from ...core.overlay import NdOverlay, Overlay
from ...core.util import LooseVersion, pd
from ...core.util import LooseVersion
from ...element import * # noqa (API import)
from ..plot import PlotSelector
from ..util import fire_colors
Expand All @@ -32,13 +32,12 @@

mpl_ge_150 = LooseVersion(mpl.__version__) >= LooseVersion('1.5.0')

if pd:
try:
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
except ImportError:
from pandas.tseries import converter
converter.register()
try:
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
except ImportError:
from pandas.tseries import converter
converter.register()


def set_style(key):
Expand Down

0 comments on commit c4a94a2

Please sign in to comment.