Flatten lists
See original GitHub issueHey,
From the dictionary:
data = {
'id': 1337,
'profiles': [
{'email': 'test@test.com'},
{'email': 'old_email@test.com'},
]
}
Which schema could I write to dump the following result?
{
"id": 1337,
"current_email": "test@test.com"
}
Assuming the latest email in the first entry from profiles
.
I imagine it should be possible with fields.Pluck
, but I can’t make it work.
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How do I make a flat list out of a list of lists? - python
To make this more readable, you can make a simple function: def flatten_list(deep_list: list[list[object]]): return list(chain.from_iterable( ...
Read more >Python: How to Flatten a List of Lists - Stack Abuse
Flattening a list of lists entails converting a 2D list into a 1D list by un-nesting each list item stored in the list...
Read more >How to flatten list in Python? - TutorialsTeacher
Flatten list of lists means getting elements of sublists into a one dimensional array like list. For example, a list [[1,2,3],[4,5,6]] is ...
Read more >Python Program to Flatten a Nested List - Programiz
Using itertools module, we can create a flattened list. chain() method from itertools module returns each element of each iterable (i.e. sub lists...
Read more >How to flatten a list of lists in Python - nkmk note
Flatten list with sum() ... You can also flatten a list of lists with the built-in function sum() . An initial value can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Indeed, it is also working. Full working example:
pass_original
is important here. By default, original data is not given topost_dump
.Thanks!
Oh right, custom field isn’t what you want. You could use a
post_dump
method instead.