Skip to content

Commit dfd1b2c

Browse files
committed
pandas imported message to 'installed'
1 parent 082fdfd commit dfd1b2c

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

plotly/figure_factory/_bullet.py

+28-23
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,15 @@ def _bullet(df, markers, measures, ranges, subtitles, titles, orientation,
160160

161161
def create_bullet(data, markers=None, measures=None, ranges=None,
162162
subtitles=None, titles=None, orientation='h',
163-
range_colors=None, measure_colors=None,
163+
range_colors=('rgb(200, 200, 200)', 'rgb(245, 245, 245)'),
164+
measure_colors=('rgb(31, 119, 180)', 'rgb(176, 196, 221)'),
164165
horizontal_spacing=None, vertical_spacing=None,
165166
scatter_options={}, **layout_options):
166167
"""
167168
Returns figure for bullet chart.
168169
169-
:param (pd.DataFrame | list) data: either a JSON list of dicts or a pandas
170-
DataFrame.
170+
:param (pd.DataFrame | list | tuple) data: either a list/tuple of
171+
dictionaries or a pandas DataFrame.
171172
:param (str) markers: the column name or dictionary key for the markers in
172173
each subplot.
173174
:param (str) measures: the column name or dictionary key for the measure
@@ -184,14 +185,14 @@ def create_bullet(data, markers=None, measures=None, ranges=None,
184185
of each subplot chart.
185186
:param (bool) orientation: if 'h', the bars are placed horizontally as
186187
rows. If 'v' the bars are placed vertically in the chart.
187-
:param (list) range_colors: a list of two colors between which all
188+
:param (list) range_colors: a tuple of two colors between which all
188189
the rectangles for the range are drawn. These rectangles are meant to
189190
be qualitative indicators against which the marker and measure bars
190191
are compared.
191-
Default=['rgb(198, 198, 198)', 'rgb(248, 248, 248)']
192-
:param (list) measure_colors: a list of two colors which is used to color
192+
Default=('rgb(200, 200, 200)', 'rgb(245, 245, 245)')
193+
:param (list) measure_colors: a tuple of two colors which is used to color
193194
the thin quantitative bars in the bullet chart.
194-
Default=['rgb(31, 119, 180)', 'rgb(176, 196, 221)']
195+
Default=('rgb(31, 119, 180)', 'rgb(176, 196, 221)')
195196
:param (float) horizontal_spacing: see the 'horizontal_spacing' param in
196197
plotly.tools.make_subplots. Ranges between 0 and 1.
197198
:param (float) vertical_spacing: see the 'vertical_spacing' param in
@@ -210,20 +211,22 @@ def create_bullet(data, markers=None, measures=None, ranges=None,
210211
import plotly.figure_factory as ff
211212
212213
data = [
213-
{"e": "Revenue", "d": "US$, in thousands", "c": [150, 225, 300],
214-
"b": [220,270], "a": [250]},
215-
{"e": "Profit", "d": "%", "c": [20, 25, 30], "b": [21, 23], "a": [26]},
216-
{"e": "Order Size", "d":"US$, average","c": [350, 500, 600],
217-
"b": [100,320],"a": [550]},
218-
{"e": "New Customers", "d": "count", "c": [1400, 2000, 2500],
219-
"b": [1000,1650],"a": [2100]},
220-
{"e": "Satisfaction", "d": "out of 5","c": [3.5, 4.25, 5],
221-
"b": [3.2,4.7], "a": [4.4]}
214+
{"label": "Revenue", "sublabel": "US$, in thousands",
215+
"range": [150, 225, 300], "performance": [220,270], "point": [250]},
216+
{"label": "Profit", "sublabel": "%", "range": [20, 25, 30],
217+
"performance": [21, 23], "point": [26]},
218+
{"label": "Order Size", "sublabel":"US$, average","range": [350, 500, 600],
219+
"performance": [100,320],"point": [550]},
220+
{"label": "New Customers", "sublabel": "count", "range": [1400, 2000, 2500],
221+
"performance": [1000, 1650],"point": [2100]},
222+
{"label": "Satisfaction", "sublabel": "out of 5","range": [3.5, 4.25, 5],
223+
"performance": [3.2, 4.7], "point": [4.4]}
222224
]
223225
224226
fig = ff.create_bullet(
225-
data, titles='e', subtitles='d', markers='a', measures='b',
226-
ranges='c', orientation='h', title='my simple bullet chart'
227+
data, titles='label', subtitles='sublabel', markers='point',
228+
measures='performance', ranges='range', orientation='h',
229+
title='my simple bullet chart'
227230
)
228231
py.iplot(fig)
229232
```
@@ -249,23 +252,25 @@ def create_bullet(data, markers=None, measures=None, ranges=None,
249252
# validate df
250253
if not pd:
251254
raise exceptions.ImportError(
252-
"'pandas' must be imported for this figure_factory."
255+
"'pandas' must be installed for this figure factory."
253256
)
254257

255-
if isinstance(data, list):
258+
if isinstance(data, (tuple, list)):
256259
if not all(isinstance(item, dict) for item in data):
257260
raise exceptions.PlotlyError(
258-
'If your data is a list, all entries must be dictionaries.'
261+
'Every entry of the data argument (a list or tuple) must be '
262+
'a dictionary.'
259263
)
260264

261265
elif not isinstance(data, pd.DataFrame):
262266
raise exceptions.PlotlyError(
263-
'You must input a pandas DataFrame or a list of dictionaries.'
267+
'You must input a pandas DataFrame, or a list or tuple of '
268+
'dictionaries.'
264269
)
265270

266271
# make DataFrame from data with correct column headers
267272
col_names = ['titles', 'subtitle', 'markers', 'measures', 'ranges']
268-
if isinstance(data, list):
273+
if isinstance(data, (tuple, list)):
269274
df = pd.DataFrame(
270275
[
271276
[d[titles] for d in data] if titles else [''] * len(data),

plotly/figure_factory/_facet_grid.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ def create_facet_grid(df, x=None, y=None, facet_row=None, facet_col=None,
778778
"""
779779
if not pd:
780780
raise exceptions.ImportError(
781-
"'pandas' must be imported for this figure_factory."
781+
"'pandas' must be installed for this figure_factory."
782782
)
783783

784784
if not isinstance(df, pd.DataFrame):

0 commit comments

Comments
 (0)