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.

Wrong exception thrown for empty dataframe

See original GitHub issue

Using the get started query example https://danfo.jsdata.org/api-reference/dataframe/danfo.dataframe.query

let data = {"A": [30, 1, 2, 3],
           "B": [34, 4, 5, 6],
           "C": [20, 20, 30, 40]}
           
let cols = ["A", "B", "C"]
let df = new dfd.DataFrame(data, { columns: cols })
df.print() //before query

let query_df = df.query({ "column": "B", "is": ">", "to": 5 })
table(query_df)

I modified the condition to

let data = {"A": [30, 1, 2, 3],
           "B": [34, 4, 5, 6],
           "C": [20, 20, 30, 40]}
           
let cols = ["A", "B", "C"]
let df = new dfd.DataFrame(data, { columns: cols })
df.print() //before query

let query_df = df.query({ "column": "B", "is": ">", "to": 40 })
table(query_df)

Error message

File format not supported for now

Expected Output: Return empty result/array

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
iGorjidoozcommented, Jan 7, 2021

Hi everyone! When I am querying a DataFrame which would return an empty result, danfojs-node throws the following error (as it is implemented in core/frame.js) Error: query returned empty data but shouldn’t it actually return an empty DataFrame like in Pandas? IMO, throwing an error breaks the chain of execution and it would make it difficult in cases where a decision is dependent on the query to return empty result or not.

0reactions
risenWcommented, Aug 31, 2021

This has been fixed in the latest conversion to TS. See #235

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrong exception thrown for empty dataframe #37 - GitHub
When I am querying a DataFrame which would return an empty result, danfojs-node throws the following error (as it is implemented in core/frame.js)...
Read more >
catch exception and return empty dataframe - Stack Overflow
This works fine when database query returns data but it throws an error when no data is returned(this is to be expected).
Read more >
error handling; pandas and data analysis
pass is a special Python statement called a “null operation” or a “no-op”; it does nothing except keep going. try: x= math.sqrt(-1) except:...
Read more >
Dealing with null in Spark - MungingData
All the blank values and empty strings are read into a DataFrame as null by ... Here's some code that would cause the...
Read more >
Indexing and Selecting Data — pandas 0.15.0 documentation
In 0.15.0 Index has internally been refactored to no longer sub-class ... If a column is not contained in the DataFrame, an exception...
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