Comments (6)
As mentioned in #11, including a subset of fields or excluding fields would also limit processing (ie. 1 and 2 in #9). As a user of the library, my use case is I have in mind that I want to process certain fields and ignore others. To me it is more intuitive to be able to specify that to the library than post processing the output of the library.
from flatten.
@mcarans let's say we have this dictionary (feel free to come up with a better example but I want us to nail down the requirements):
d = {
'a': [1,2,3],
'b': {'a': [1,2,3], 'b': [4,5,6]},
'c': 'c',
'd': {'a': 5}
}
What would you want to pass to flatten
and what do you want to see in return?
from flatten.
I would want to pass in some way 'a' and get back from flatten 'b', 'c' and 'd' flattened. The 'a' : [1,2,3] would not be output at all. The other 'a' under 'b' and 'd' would be output ie. we only apply this at the root level.
from flatten.
If it's root-level and the argument you pass is the set to be filtered I think I've addressed it in #11 . Here's the documentation I wrote:
https://github.com/amirziai/flatten/tree/flatten-ignore-keys%239#ignore-root-keys
Am I missing something?
from flatten.
@amirziai I see that you have implemented the above which is what I would have called 1/2 from my list ie. inclusion/exclusion of fields. For 3 and 4, I meant that all fields would be included, but that these options would enable or disable flattening of those fields ie. with your example above if we disabled flattening for 'b', then our output would have a column entitled 'b'
with contents {'a': [1,2,3], 'b': [4,5,6]}
(ie. it is not flattened but it is outputted).
from flatten.
@mcarans I think I understand now. The point of flatten
to me is that the resulting object has no structure (no iterables other than strings are present as values of the flat dictionary). This way you can easily pass the dictionary to Pandas. I see the use case though but I think that it should live outside of flatten
. Feel free to open a new issue for it.
from flatten.
Related Issues (20)
- double quotes vs single quotes
- Regression 0.1.6 -> 0.1.7 for numpy arrays HOT 2
- Unable to use flatten + unflatten when original dict key names contain seperator char HOT 1
- Data is lost if unflatten column name begins with name HOT 2
- More complex flattening? HOT 2
- ModuleNotFoundError for v0.1.8 HOT 11
- The util namespace HOT 4
- Still maintained? HOT 1
- flatten_preserve_lists returns a list instead of dict HOT 1
- flatten_preserve_lists is failed to flatten json data which includes an array with more than 10 rows HOT 1
- Error if a key is substring of another key HOT 1
- flatten_preserve_lists is failed to flatten data which has array in array
- Exploding non-nested lists rather than unpacking into separate columns
- Two different install instructions on PyPI HOT 2
- flatten option for root keys to ignore keeps some data from the root keys
- add type hints or stub file
- Several issues with flatten_preserve_lists
- Issue with unflatten
- Unflat and flat with list format a[0] instead of a.0
- Order preserving
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flatten.