Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If dataframe has column called 'index,' df.index refers to the column, causing hard-to-decipher errors. #550

Open
maxhosler opened this issue Jan 26, 2023 · 2 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@maxhosler
Copy link

Describe the bug
When creating a DataFrame by providing an Object, if one of the columns is called 'index,' then 'df.indexwill point to that column instead of the actualDataFrame` index. This caused very hard-to-decipher errors when I was working with a table I did not know contained such a column.

To Reproduce

let obj = {
foo: [1,2,3,4,5],
bar: [5,6,7,8,9],
index: ['a','b','c','d','e']
}
df = new DataFrame(obj).setIndex('foo')

df.index.includes(1) //Throws error

Expected behavior
df.index should give the index of df. Failing that, a warning that I've created a DataFrame with a column named index.

@Ausqa21
Copy link

Ausqa21 commented Mar 23, 2023

I have this same issue when I have a json file with some data which has a column named "index",
This is for when I have only one record in the json

subIdx = this.index.slice(0, maxRow);
                    ^
TypeError: this.index.slice is not a function

and this is for when I have multiple records

Error: IndexError: Row index must contain unique values

and when I get rid of the column named "index", it works.

Sample data

[
    {
        "_id": "6419c10b7027bac2b373350c",
        "index": 1,
        "guid": "aa9af45c-3435-473d-bbf1-e7d5ef276684",
        "isActive": false,
        "balance": "$2,489.81",
        "picture": "http://placehold.it/32x32",
        "age": 32,
        "eyeColor": "green",
        "name": "Mara Herrera",
        "gender": "female",
        "company": "PHARMEX",
        "email": "[email protected]",
        "phone": "+1 (841) 575-2666",
        "address": "195 Front Street, Emerald, Colorado, 2400",
        "about": "Reprehenderit non qui officia cupidatat minim ad aliquip est eiusmod sit fugiat dolore consequat voluptate. Exercitation in et non fugiat aliquip. Ullamco laboris proident duis commodo pariatur enim tempor velit. Eiusmod culpa adipisicing ad dolor cupidatat voluptate officia cillum occaecat anim mollit velit.\r\n",
        "registered": "2021-08-08T02:45:49 -00:00",
        "latitude": 47.497364,
        "longitude": -36.733145,
        "tags": [
            "deserunt",
            "incididunt",
            "quis",
            "consequat",
            "dolor",
            "tempor",
            "nisi"
        ],
        "friends": [
            {
                "id": 0,
                "name": "Yang Landry"
            },
            {
                "id": 1,
                "name": "Peterson Salazar"
            },
            {
                "id": 2,
                "name": "Consuelo White"
            }
        ],
        "greeting": "Hello, Mara Herrera! You have 3 unread messages.",
        "favoriteFruit": "strawberry"
    }
]

@kitfit-dave
Copy link
Contributor

Yes, I can confirm that creating a DataFrame with a column named 'index', or adding a column named 'index', breaks the DataFrame (prints nothing, does not seem to have any rows)

@risenW risenW added bug Something isn't working enhancement New feature or request labels Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants