Skip to content
New issue

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

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

Already on GitHub? # to your account

How to access nested dictionaries? #8

Open
aiqc opened this issue Aug 23, 2022 · 3 comments
Open

How to access nested dictionaries? #8

aiqc opened this issue Aug 23, 2022 · 3 comments

Comments

@aiqc
Copy link

aiqc commented Aug 23, 2022

I have a file of records structured like so:

[
    {
        "case_id": 1,
        "demographic": {
            "race": "white",
            "age": 55,
        }
    },
    {
        "case_id": 2,
        "demographic": {
            "race": "white",
            "age": 65,
        }
    },
    {
        "case_id": 3,
        "demographic": {
            "race": "black",
            "age": 57,
        }
    }
]

I can access case id fine

q.where('case_id', '=', 1).get()

But I can't seem to use at to drill into the demographic key

q.at('demographic')

"KeyError: 'Key not exists'"
@aiqc
Copy link
Author

aiqc commented Aug 23, 2022

Related/duplicate: #2

@aiqc
Copy link
Author

aiqc commented Aug 23, 2022

This works:

q.at('0.demographic').get()

But I can't figure out how to make it do at('all.demographic')

@wesley-staples
Copy link

wesley-staples commented Jul 17, 2024

I have just run into this same issue. Has anyone found a workaround yet? @s1s1ty if you have some time could you look into this?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants