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.

Allow `@` queries for metadata

See original GitHub issue

Metadata-based querying of Epochs is very powerful. For example, these work:

import mne
path_kword = mne.datasets.kiloword.data_path() + '/kword_metadata-epo.fif'
kword = mne.read_epochs(path_kword)
kword["NumberOfLetters == 4 & ConsonantVowelProportion < .5"], kword["WORD == 'area'"]

But what doesn’t work is pulling a variable from the current scope with @:

word = 'area'
kword.metadata.query("WORD == @word")

This works, in Pandas. But this errors:

kword["WORD == @word"]

Would be cool to have!

@choldgraf

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
choldgrafcommented, Aug 12, 2018

I’m pretty sure that they accomplish mostly the same thing, but that eval returns a boolean mask according to whatever the query was, while query returns the DataFrame object itself. So probably we use eval because we want that mask somewhere else in the code, I’m guessing.

0reactions
drammockcommented, Nov 24, 2020

… 2 years later, I tried to get this to work by manipulating the level kwarg (how far up the call stack pandas looks for @variables), as well as passing local_dict=globals() and a few other hackish things; nothing worked. Given that it’s possible to generally replace use of @ with a fairly similar f-string nowadays (e.g., epochs['WORD in @words'] becomes epochs[f'WORD in {words}']) I think we can close this as YAGNI.

Read more comments on GitHub >

github_iconTop Results From Across the Web

5. Metadata Queries - SQL Cookbook [Book] - O'Reilly
Metadata Queries This chapter presents recipes that allow you to find information about a given schema. For example, you may wish to know...
Read more >
Actions defined by Database Query Metadata Service
Actions Description Access level CreateFavoriteQuery Grants permission to create a new favorite query Write CreateQueryHistory Grants permission to add a query to the history Write CreateTab...
Read more >
Query Metadata: /Documentation - LabKey Support
Open the schema browser via (Admin) > Go To Module > Query. · Select an individual schema and query/table in the browser and...
Read more >
Metadata Visibility Configuration - SQL Server - Microsoft Learn
Learn how to configure metadata visibility for securables that a user owns or has been granted permission to in SQL Server.
Read more >
A complete guide to T-SQL Metadata Functions in SQL Server
This article describes metadata functions in SQL Server using T- SQL.
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