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.

Creating DataFrame from json that contains "index" key/property causes error

See original GitHub issue

The Following Code:

const jsonData = [{name:'test1',index: 0},{name:'test2',index: 1}]
const df = new dfd.DataFrame(jsonData);

This will cause the error: UnhandledPromiseRejectionWarning: TypeError: Cannot set property index of [object Object] which has only a getter

Looks like within the DataFrame class “index” is reserved


class DataFrame extends _generic.default {
  constructor(data, kwargs) {
    super(data, kwargs);

    this.__set_column_property();
  }
 __set_column_property() {
    let col_vals = this.col_data;
    let col_names = this.column_names;
    col_vals.forEach((col, i) => {
      this[col_names[i]] = null;   <<<< Error happens here
      Object.defineProperty(this, col_names[i], {
        get() {
          return new _series.Series(this.col_data[i], {
            columns: col_names[i],
            index: this.index
          });
        },

        set(value) {
          this.addColumn({
            column: col_names[i],
            value: value
          });
        }

      });
    });
  }

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
mjarmoccommented, Dec 5, 2020

The same happens if size key is present in data.

const df = new dfd.DataFrame(jsonData);
0reactions
github-actions[bot]commented, Jul 22, 2021

Stale issue message

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reading Json file as Pandas Dataframe error - Stack Overflow
I think you can use modul json for reading file.json and then DataFrame constructor : import pandas as pd import json with open('file.json') ......
Read more >
Three Cases When Parsing JSON Documents In A Python ...
Python Pandas DataFrame convert and normalise JSON documents objects with NULL ... we have to make up the dictionary using the indexes of...
Read more >
pandas.DataFrame.to_json — pandas 1.5.2 documentation
Whether to include the index values in the JSON string. Not including the index ( index=False ) is only supported when orient is...
Read more >
Indexer errors and warnings - Azure Cognitive Search
Ensure all documents have valid document keys. The document key is determined by setting the 'key' property as part of the index definition....
Read more >
Loading JSON data from Cloud Storage | BigQuery
create. Each of the following predefined IAM roles includes the permissions that you need in order to load data into a BigQuery table...
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