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.

Normalize flatten

See original GitHub issue

I think it would greatly simplify downstream usage of twarc.expansions.flatten in plugins if flatten() always returned a list of tweet objects regardless of whether it was passed a bundled tweet {"data": {}}, a bundled list of tweets {"data": [{...}]} or an already flattened tweet {"id": "..."}.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
edsucommented, Apr 16, 2021

Thanks for those pointers @igorbrigadir – it would be great if they solved this problem for us. But I think we should move forward with our own solution until it materializes.

1reaction
edsucommented, Apr 16, 2021

Because it is seen as additive, not destructive, I’m pretty sure flatten() returns the same structure it was given, e.g {"data": []} or {"data": {}}. It can be a bit tedious to have to unpack that in plugins, and I found myself copy pasting the same code.

After a night’s sleep I think @SamHames is right and that flatten should be left as non-destructive, and what is needed is something new that will create a singular JSON representation based off of either the v1 or v2 representation. So I’m going to close this and focus on #412 instead. It’s just a bigger job because I need to read the standard more closely.

Read more comments on GitHub >

github_iconTop Results From Across the Web

All Pandas json_normalize() you should know for flattening ...
In this article, you'll learn how to use Pandas's built-in function json_normalize() to flatten those 2 types of JSON into Pandas DataFrames ...
Read more >
Python Pandas - Flatten nested JSON - GeeksforGeeks
Max number of levels(depth of dict) to normalize. ... Use pandas json_normalize on this JSON data structure to flatten it to a flat...
Read more >
Flatten nested JSON with pandas.json.normalize()
Any idea how to make the json_normalize function of pandas more flexible and independent of entries of the json response? python · json...
Read more >
pandas.json_normalize — pandas 1.5.2 documentation
Normalize semi-structured JSON data into a flat table. Parameters. datadict or list of dicts. Unserialized JSON objects. record_pathstr or list of str, ...
Read more >
Flatten / Normalize Nested JSON Data - Kaggle
Hey all,. Just did a quick blog post on how to flatten / normalize any nested JSON to structured relational tables for analysis....
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