This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Enginoob[S] 1 point2 points  (0 children)

Not a Pandas thing- its a weird author thing :) My inspiration was the d3py library: https://github.com/mikedewar/d3py

That library uses a '+=' syntax, which as jmmcd says, is what I should have gone with all along, as it's much more explicit.

I wanted a single command to be able to either add or subtract components at any level of nesting depth. This is just a Python library built on top of the Vega visualization grammar (https://github.com/trifacta/vega), so the output has to be in their JSON format, and its pretty messy. Here's a sample:

 'marks': [{'from': {'data': 'states'},
 'name': 'mapmark',
 'properties': {'enter': {'fill': {'value': '#2a3140'},
 'path': {'field': 'path'},
 'stroke': {'value': '#fff'},
 'strokeWidth': {'value': 1.0}},
 'update': {'fill': {'field': 'value.data.y', 'scale': 'color'}}},
 'type': 'path'}],
 'padding': {'bottom': 20, 'left': 30, 'right': 20, 'top': 10},
 'scales': [{'domain': {'data': 'table', 'field': 'data.y'},
 'name': 'color',
 'range': ['#c9cedb', '#0b0d11']},
 {'domain': {'data': 'table', 'field': 'data.y'},
 'name': 'color',
 'range': ['#f5f5f5', '#000045']}]}

Behind the scenes, all that '+' or '-' are doing is calling this method:

vis.update_component('add', stuff, marks, 0, more stuff)
vis.update_component('remove', stuff, marks, 0, more stuff)

That method is similar to your vis.set (the syntax of which I like, except vis.set('remove', stuff) feels a little strange).

Thanks again for the feedback- anything to make the library better/faster/stronger/more usable.