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.

[transform_filter] - condition not working

See original GitHub issue

I do not understand why the condition in transform_filter is not working and have not found any explanation around (including documentation).

  1. The problem seems to be in FilterTransoform method.

  2. another issue: where and how am I supposed to put/write the ‘background’ to change the default transparent?

import altair.vegalite.v2 as alt
import pandas as pd

stocks = pd.read_csv(data.stocks.url)
type(stocks)
stocks.head()
stocks.symbol
stocks['symbol'] = stocks['symbol'].astype('category') # forced to be a factor
stocks.symbol

base = alt.Chart(stocks).encode(
    x='date:T',
    y='price:Q',
    color='symbol:N'
).transform_filter(
    stocks.symbol == 'GOOG' # problem is here
)
base.mark_line()

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
jakevdpcommented, Apr 5, 2018

Another thing (I should really read questions more carefully before answering 😄)

You’re rendering your plot with Vega-Lite version 1; this doesn’t support everything that Altair version 2 supports, and so filter transforms, background configurations, etc. will not always work properly, and some specifications will simply fail to produce a chart at all.

nteract does not support Vega-Lite 2 yet, and so I would not recommend it as a frontend for Altair at this time. You might try JupyterLab, Jupyter Notebook, or CoLab, until the nteract project updates its dependencies.

1reaction
jakevdpcommented, Apr 5, 2018

Oh, noticed your other question about backgrounds. If you want to configure the background, you can use:

Chart().configure(
    background='white'
)

The background is transparent by default, as mentioned here: https://vega.github.io/vega-lite/docs/config.html#top-level-config

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't get transform_filter to work in Altair - Stack Overflow
I getting the separate charts (bar and rule to work) was easy, but I run into issues in making mark_rule interactive. import altair...
Read more >
Filter Transform — Altair 4.2.0 documentation
The filter transform removes objects from a data stream based on a provided filter expression, selection, or other filter predicate. A filter can...
Read more >
Linkify.TransformFilter - Android Developers
Driver. On this page; Summary. Public methods. Public methods ... TransformFilter enables client code to have more control over how matched patterns are ......
Read more >
Domain Transform Filter and Spatial-Aware Collaborative ...
To overcome this problem, a classification method (DF+SACR) that includes domain transform filter (DF) and spatial-aware CR (SACR) is ...
Read more >
5. Filtering Data - ParaView Documentation
If a menu item is disabled, it implies that the active source does not produce data ... 5.11 The Transform filter showing the...
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