question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to transform_filter with a test against a list?

See original GitHub issue

Here’s what I mean.

import altair as alt
from vega_datasets import data
df = data.stocks()
alt.Chart(df).mark_line().encode(
    x='date:T',
    y='price:Q',
    color="symbol",
    column="symbol:N"
).transform_filter(alt.datum.symbol in ["AAPL", "AMZN"])

I’m trying to spit out a restricted list of two charts, for Apple and Amazon. But this raises an error.

SchemaValidationError: Invalid specification

        altair.vegalite.v2.schema.core.FilterTransform ->filter, validating 'anyOf'

        True is not valid under any of the given schemas

This is a use case I see as pretty common. For instance, after grouping on a field I’d like to spit out mini multiple charts of the top ten ranking values.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
jakevdpcommented, Mar 29, 2018

Oh, I should have also mentioned that a wrapper for this exists in Altair:

transform_filter(alt.FieldOneOfPredicate(field='symbol', oneOf=['AAPL', 'AMZN']))
2reactions
jakevdpcommented, Mar 29, 2018

It would not be possible to make this work using something like alt.datum.symbol in ["AAPL", "AMZN"], because in Python x in y always returns a boolean, and the language provides no mechanism to overload the behavior of the in operator.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating a Drop Down Filter to Extract Data Based on Selection
Here are the steps to create a drop-down filter that will extract data for the selected item: Create a Unique list of items....
Read more >
Quick start: Filter data by using an AutoFilter - Microsoft Support
Use the AutoFilter to filter a range of data in Excel 2010 and learn how to ... Selecting values from a list and...
Read more >
Using the Excel FILTER Function to Create Dynamic Filters
Learn how to use the new FILTER function in Excel to create dynamic filters. These dynamic filters will update filter results immediately ...
Read more >
Excel FILTER function with formula examples - Ablebits
See how to filter in Excel dynamically with formulas. Examples to filter duplicates, cells containing certain text, with multiple criteria, ...
Read more >
How to Use Slicers With Excel Advanced Filter - Contextures
Use Excel Slicers to select criteria, show matching records from list. View specific data, keep original records safe on hidden worksheet.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found