holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.71k stars 403 forks source link

Spatialpandas required for Datashader? #4648

Open jbednar opened 4 years ago

jbednar commented 4 years ago

Shouldn't I be able to use HoloViews with Datashader without SpatialPandas installed?

import pandas as pd
import hvplot.pandas
from pandas import Timestamp

df = pd.DataFrame(
       {'m': {
          Timestamp('00:00:00'): -0.5,
          Timestamp('01:00:00'): 0.6,
          Timestamp('02:00:00'): -1,
          Timestamp('09:00:00'): 1}})
df.hvplot(datashade=True)
lib/python3.7/site-packages/holoviews/core/data/interface.py in <listcomp>(.0)
    262         prioritized = [cls.interfaces[p] for p in datatype
    263                        if p in cls.interfaces]
--> 264         head = [intfc for intfc in prioritized if intfc.applies(data)]
    265         if head:
    266             # Prioritize interfaces which have matching types

lib/python3.7/site-packages/holoviews/core/data/spatialpandas.py in applies(cls, obj)
     31         if not cls.loaded():
     32             return False
---> 33         from spatialpandas import GeoDataFrame, GeoSeries
     34         is_sdf = isinstance(obj, (GeoDataFrame, GeoSeries))
     35         if 'geopandas' in sys.modules and not 'geoviews' in sys.modules:

ImportError: cannot import name 'GeoDataFrame' from 'spatialpandas' (unknown location)
jbednar commented 4 years ago

Same code works without datashade=True, but for some reason HoloViews is expecting spatialpandas to be importable even though I don't have it installed at all in this environment and this is just an ordinary Pandas dataframe.

Oddly, the behavior is different between Jupyter and the commandline where I launched Jupyter. From the commandline, import spatialpandas fails, as it should, because there's no spatialpandas installed in this conda environment. But in Jupyter, importing it gives an empty module:

image

It being empty is why I get the messages above, but I can't tell why I have this empty spatialpandas module that's only importable in Jupyter...