Module pandas_profiling.utils.common
Common util functions (e.g. missing in Python).
Source code
"""Common util functions (e.g. missing in Python)."""
import collections
from pathlib import Path
def update(d: dict, u: dict) -> dict:
""" Recursively update a dict.
Args:
d: Dictionary to update.
u: Dictionary with values to use.
Returns:
The merged dictionary.
"""
for k, v in u.items():
if isinstance(v, collections.Mapping):
d[k] = update(d.get(k, {}), v)
else:
d[k] = v
return d
def _copy(self, target):
"""Monkeypatch for pathlib
Args:
self:
target:
Returns:
"""
import shutil
assert self.is_file()
shutil.copy(str(self), str(target)) # str() only there for Python < (3, 6)
Path.copy = _copy
Functions
def update(d, u)
-
Recursively update a dict.
Args
d
- Dictionary to update.
u
- Dictionary with values to use.
Returns
The merged dictionary.
Source code
def update(d: dict, u: dict) -> dict: """ Recursively update a dict. Args: d: Dictionary to update. u: Dictionary with values to use. Returns: The merged dictionary. """ for k, v in u.items(): if isinstance(v, collections.Mapping): d[k] = update(d.get(k, {}), v) else: d[k] = v return d