profile
viewpoint

ianlini/flatten-dict 63

A flexible utility for flattening and unflattening dict-like objects in Python.

ianlini/feagen 33

(deprecated) A fast and memory-efficient Python data engineering framework for machine learning.

ianlini/drone-example 8

A Drone CI/CD example for single machine.

ianlini/bistiming 7

A logging-friendly stopwatch and profiling tool for Python.

ianlini/dagian 7

A data-centric DAG framework in Python.

ianlini/mkdir-p 7

Python 2 and 3 compatible POSIX mkdir -p.

ianlini/serialtime 5

A Python serialization tool containing many serialization and deserialization shortcuts with timing.

ianlini/pandas-pitfalls 4

Illustrate the magic in pandas by some pitfalls.

ianlini/calculator 0

web programming week 4 class

issue commentianlini/flatten-dict

Feature Request: Switch "don't flatten embedded lists"

Your expected and got results are not readable and has syntax error, and again, the default behavior is not flattening list. I guess you got your result by using flatten(d, enumerate_types=(list,)). enumerate_types=(list,) tells the function to flatten the list. If you explicitly tell the function to flatten the list, why do you want it not to flatten the list?

I tried to guess what you actually want to do:

In [2]: a
Out[2]:
[{'company': {'name': 'Miller Ltd.',
   'employee': [{'name': 'John Forster', 'department': 'sales'},
    {'name': 'Bud Ryan', 'department': 'finance'},
    {'name': 'Brian Walker', 'department': 'sales'}],
   'address': {'zip': 12345, 'city': 'cleveland', 'street': '255 main road'}}},
 {'company': {'name': 'Mercury & Flint',
   'employee': [{'name': 'Carl Sanders', 'department': 'manufactoring'},
    {'name': 'Marc Rogers', 'department': 'customer service'},
    {'name': 'Glenn Scott', 'department': 'sales'}],
   'address': {'zip': 34567,
    'city': 'austin',
    'street': '1023 peters drive'}}}]
In [7]: [flatten(d) for d in a]
Out[7]:
[{('company', 'name'): 'Miller Ltd.',
  ('company', 'employee'): [{'name': 'John Forster', 'department': 'sales'},
   {'name': 'Bud Ryan', 'department': 'finance'},
   {'name': 'Brian Walker', 'department': 'sales'}],
  ('company', 'address', 'zip'): 12345,
  ('company', 'address', 'city'): 'cleveland',
  ('company', 'address', 'street'): '255 main road'},
 {('company', 'name'): 'Mercury & Flint',
  ('company',
   'employee'): [{'name': 'Carl Sanders',
    'department': 'manufactoring'}, {'name': 'Marc Rogers', 'department': 'customer service'}, {'name': 'Glenn Scott',
    'department': 'sales'}],
  ('company', 'address', 'zip'): 34567,
  ('company', 'address', 'city'): 'austin',
  ('company', 'address', 'street'): '1023 peters drive'}]
xbln

comment created time in 17 days

issue commentianlini/flatten-dict

Feature Request: Switch "don't flatten embedded lists"

I'm sorry. I didn't get it. Could you give me an example?

The default behavior of both flatten() and unflatten() doesn't do anything to the list.

xbln

comment created time in 19 days

startedgotcha/ipdb

started time in a month

startedcontainous/traefik

started time in 2 months

startedpi-hole/docker-pi-hole

started time in 2 months

delete branch ianlini/flatten-dict

delete branch : use-poetry

delete time in 2 months

delete branch ianlini/flatten-dict

delete branch : fix-empty-dict

delete time in 2 months

created tagianlini/flatten-dict

tag0.3.0

A flexible utility for flattening and unflattening dict-like objects in Python.

created time in 3 months

release ianlini/flatten-dict

0.3.0

released time in 3 months

push eventianlini/flatten-dict

Ian Lin

commit sha 85263bdeb5040a8561b4ff8bf9f808afccd8f175

Add build script and bump version to 0.3.0 (#29) * bump version to 0.3.0 * add build script

view details

push time in 3 months

delete branch ianlini/flatten-dict

delete branch : bump-version

delete time in 3 months

push eventianlini/flatten-dict

Ian Lin

commit sha 457e6be07e9eb4d69120ca4d256de80bdcc1a052

add build script

view details

push time in 3 months

create barnchianlini/flatten-dict

branch : bump-version

created branch time in 3 months

push eventianlini/flatten-dict

Ian Lin

commit sha 67d1043afd92661244ea4c4bb5f85fc1db049f8f

Improve docs (#28) * update docs for make_reducer * update docs for make_splitter

view details

push time in 3 months

delete branch ianlini/flatten-dict

delete branch : improve-readme

delete time in 3 months

PR merged ianlini/flatten-dict

Improve docs
+161 -168

0 comment

4 changed files

ianlini

pr closed time in 3 months

PR opened ianlini/flatten-dict

Improve docs
+161 -168

0 comment

4 changed files

pr created time in 3 months

push eventianlini/flatten-dict

Ian Lin

commit sha 41b8a74bb8772e18893ffac5230751e214bd43e1

update docs for make_splitter

view details

push time in 3 months

create barnchianlini/flatten-dict

branch : improve-readme

created branch time in 3 months

push eventianlini/flatten-dict

Ian Lin

commit sha 9d0e9cd00460ae48fad6ce83e2828736ff4a0976

Improve CI (#27) * upgrade packages * fix flake8 * pytest config * fix python 2.7 and 3.5 test errors * upgrade travis 3.8 env

view details

push time in 3 months

delete branch ianlini/flatten-dict

delete branch : improve-CI

delete time in 3 months

PR merged ianlini/flatten-dict

Improve CI
+393 -83

0 comment

6 changed files

ianlini

pr closed time in 3 months

PR opened ianlini/flatten-dict

Improve CI
+393 -83

0 comment

6 changed files

pr created time in 3 months

create barnchianlini/flatten-dict

branch : improve-CI

created branch time in 3 months

push eventianlini/flatten-dict

Henry Sorsky

commit sha ef4fce2d9b29c9bcc50654a9f5a7e63c137b78bb

add maker functions for reducers and splitters (#25) (resolved #16) * add makers * remove abbreviations * update doc style

view details

push time in 3 months

PR merged ianlini/flatten-dict

add maker functions for reducers and splitters

This PR proposes to add functions that return reducer and splitter functions rather than having to write them out yourself (i.e. for delimiters other than "dot" and "underscore")

+73 -2

2 comments

3 changed files

hsorsky

pr closed time in 3 months

issue commentianlini/flatten-dict

Feature Request: Flatten until given depth (keep the rest as dict)

Is this the same as #22 ?

jesperkristensen58

comment created time in 3 months

Pull request review commentianlini/flatten-dict

add maker functions for reducers and splitters

 def underscore_reducer(k1, k2):         return k2     else:         return "{0}_{1}".format(k1, k2)+++def make_reducer(delim):+    """Create a reducer with a custom delimiter.++    :param delim: delimiter to use to join keys.

I actually use numpy-style docstring, so this should be:

"""Create a reducer with a custom delimiter.

Parameters
----------
delimiter : str
    Delimiter to use to join keys.

Returns
-------
f : callable
    Callable that can be passed to `flatten()`'s `reducer` argument.
"""
hsorsky

comment created time in 3 months

Pull request review commentianlini/flatten-dict

add maker functions for reducers and splitters

 def underscore_reducer(k1, k2):         return k2     else:         return "{0}_{1}".format(k1, k2)+++def make_reducer(delim):

I prefer not using abbreviation here. (delim -> delimiter)

hsorsky

comment created time in 3 months

pull request commentianlini/flatten-dict

add maker functions for reducers and splitters

Thanks for your contribution! This is exactly what I thought in #16, though I would use a different approach. Anyway, your approach is quite good for an initial design. We just need to change some style related things, and then I will merge this PR and release a new version.

hsorsky

comment created time in 3 months

more