File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 44from datetime import datetime
55import numpy as np
66
7+ import pandas as pd
8+
9+ from ._utils import _fetch
10+
11+ def _normalize_data (spec ):
12+ """Converts the data to a Pandas dataframe
13+
14+ Parameters
15+ ----------
16+ spec : dict
17+ The vega-lite specification in json format
18+
19+ Returns
20+ -------
21+ dict
22+ The vega-lite specification with the data format fixed to a Pandas dataframe
23+
24+ Raises
25+ ------
26+ ValidationError
27+ Raised when the specification does not contain any data attribute
28+
29+ NotImplementedError
30+ Raised when the data specification has an unsupported data source
31+ """
32+
33+ if not spec .get ('data' ):
34+ raise ValidationError ('Please specify a data source.' )
35+
36+ if spec ['data' ].get ('url' ):
37+ df = pd .DataFrame (_fetch (spec ['data' ]['url' ]))
38+ elif spec ['data' ].get ('values' ):
39+ df = pd .DataFrame (spec ['data' ]['values' ])
40+ else :
41+ raise NotImplementedError ('Given data specification is unsupported at the moment.' )
42+
43+ del spec ['data' ]
44+ spec ['data' ] = df
45+
46+ return spec
47+
748def _locate_channel_dtype (chart , channel ):
849 """Locates dtype used for each channel
950 Parameters
You can’t perform that action at this time.
0 commit comments