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.

Update expression parser to support indirect column name references?

See original GitHub issue

The following code (within an observable notebook cell) runs just fine:

{
  let df = aq.from([{ a: 1 }, { a: 2 }]);
  return df.derive({ b: row => row['a'] + 1 }).view(10);
}

But if I try and make the column name a variable, it fails:

{
  let df = aq.from([{ a: 1 }, { a: 2 }]);
  let col = 'a';
  return df.derive({ b: row => row[col] + 1 }).view(10);
}

I suppose I’m just not understanding the scope in which the lambda gets evaluated, or something. What is the right way to use variable names within the lambdas that get passed to derive?

Notebook: https://observablehq.com/@pwills/arquero-confusions

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
jheercommented, Jan 15, 2021

Arquero v2.1.3 includes a fix so that you should now be able to use params and self-contained expressions to specify column name references. The importable Arquero observable notebook has also been updated.

0reactions
ericemc3commented, Jul 27, 2021

or

  const attr = "tags", r = /[\[\]]/g ;

  return aq.from([{ tags: "[1,2,3]" }]).derive({
    tags_cleaned5: aq.escape(d => d[attr].replace(/[\[\]]/g, "")),
    tags_cleaned6: `d => op.replace(d.${attr}, ${r}, "")`
  })
Read more comments on GitHub >

github_iconTop Results From Across the Web

how to reference column name in expression for upd...
I'm trying to build a flow that references the column name in the excel 'update a row in a table' connector via expression...
Read more >
Referring to data.table columns by names saved in variables
I know one way to extract the string name from a quoted expression - it's not pretty, but it works. Here's an example...
Read more >
Excel INDIRECT function - basic uses and formula examples
The INDIRECT function in Excel returns a cell reference from a text ... And now, all you have to do is to enter...
Read more >
Formula Parse Errors In Google Sheets And How To Fix Them
I'll help you understand and fix Google Sheets formula parse errors, ... Another reason for a #NAME? error is referencing a named range...
Read more >
Update expressions - Amazon DynamoDB
Update the ProductCategory and Price attributes. aws dynamodb update-item \ --table-name ProductCatalog \ --key '{"Id": ...
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