Skip to content

Conversation

@alishobeiri
Copy link
Contributor

@alishobeiri alishobeiri commented Jun 23, 2017

Now selects first element in series rather than 0th index item - old way could cause problems when the dataframe doesn't start at index 0 but rather starts at a higher number. Happened to me :P

Now selects first element in series rather than 0th element - old way could cause problems when the dataframe being drawn doesn't start at index 0 and starts at a higher number. Happened to me :P
I was getting error that kwargs is undefined:

```NameError                                 Traceback (most recent call last)
<ipython-input-173-30fb7f3aeb2e> in <module>()
      9     facet_row='cut',
     10     color_name='depth',
---> 11     facet_col='z'
     12 
     13 )

/home/alishobeiri/anaconda2/lib/python2.7/site-packages/plotly/figure_factory/_facet_grid.pyc in create_facet_grid(df, x, y, facet_row, facet_col, color_name, colormap, color_is_cat, facet_row_labels, facet_col_labels, height, width, trace_type, scales, dtick_x, dtick_y, show_boxes, ggplot2, binsize, **kwargs)
    867                     facet_row_labels, facet_col_labels, trace_type,
    868                     flipped_rows, flipped_cols, show_boxes, marker_color,
--> 869                     kwargs_trace, kwargs_marker
    870                 )
    871 

/home/alishobeiri/anaconda2/lib/python2.7/site-packages/plotly/figure_factory/_facet_grid.pyc in _facet_grid_color_numerical(df, x, y, facet_row, facet_col, color_name, colormap, num_of_rows, num_of_cols, facet_row_labels, facet_col_labels, trace_type, flipped_rows, flipped_cols, show_boxes, marker_color, kwargs_trace, kwargs_marker)
    414                         type=trace_type,
    415                         showlegend=False,
--> 416                         **kwargs
    417                     )
    418                 fig.append_trace(trace, row_count + 1, col_count + 1)

NameError: global name 'kwargs' is not defined ```

Thought it might be because kwargs should actually be kwards_trace - not sure tho
@alishobeiri alishobeiri changed the title Changed integer based indexing to location based index Changed integer based indexing to location based index - changed kwargs to kwargs_trace Jun 23, 2017
@alishobeiri alishobeiri changed the title Changed integer based indexing to location based index - changed kwargs to kwargs_trace Changed integer based indexing to location based index Jun 23, 2017
show_legend = False
if color_name:
if isinstance(df[color_name][0], str) or color_is_cat:
if isinstance(df[color_name].iloc[0], str) or color_is_cat:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there other places in the code where this happens?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alishobeiri There's a elif isinstance(df[color_name][0], Number): line a little further down the code that you can change too.

Thanks for doing this! Awesome stuff.

@chriddyp
Copy link
Member

Looks good! @alishobeiri - could you add a simple test that breaks before this code was applied but is fixed after this code was applied?
@Kully - this is your section of the code, I'll let you review it more thoroughly.

@alishobeiri
Copy link
Contributor Author

alishobeiri commented Jun 26, 2017

diamonds =

carat cut color clarity depth table price x y z cut-labels color-labels clarity-labels
0 0.23 5 2 2 61.5 55.0 326 3.95 3.98 2.43 Ideal E SI2
1 0.21 4 2 3 59.8 61.0 326 3.89 3.84 2.31 Premium E SI1
2 0.23 2 2 5 56.9 65.0 327 4.05 4.07 2.31 Good E VS1
3 0.29 4 6 4 62.4 58.0 334 4.20 4.23 2.63 Premium I VS2
4 0.31 2 7 2 63.3 58.0 335 4.34 4.35 2.75 Good J SI2

Error code:

df = deepcopy(diamonds[2:])
fig = ff.create_facet_grid(
    df,
    x='x',
    y='y',
    color_name='x'
) 

df starts at 2 so there is a key error thrown

type=trace_type,
showlegend=False,
**kwargs
**kwargs_trace
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

@Kully
Copy link
Contributor

Kully commented Jun 27, 2017

💃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants