In [13]:
import numpy as np
# `numpy.random` uses its own PRNG.
np.random.seed(444)
np.set_printoptions(precision=3)

df = np.random.laplace(loc=15, scale=3, size=500)
df[:5]
np.array([18.406, 18.087, 16.004, 16.221,  7.358])

hist, bin_edges = np.histogram(df)

In [14]:
print(hist, bin_edges)


[ 13  23  91 261  80  21   7   2   1   1] [ 2.11   5.874  9.638 13.402 17.166 20.93  24.694 28.458 32.222 35.986
 39.749]

In [15]:
df = pd.Series(data).value_counts()


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-15-7571c27ba5e5> in <module>
----> 1 df = pd.Series(data).value_counts()

NameError: name 'pd' is not defined

In [17]:
import pandas as pd
df = pd.DataFrame({'c':[1,1,2,2,3,3],'L0':['a','a','b','c','d','e'],'L1':['a','b','c','e','f','e']})

In [20]:
df_1 = pd.crosstab(df.c, df.L0)
print(df_1)
# print(df)


L0  a  b  c  d  e
c                
1   2  0  0  0  0
2   0  1  1  0  0
3   0  0  0  1  1

In [22]:
a = [{'count': 2, 'value': '10'}, {'count': 2, 'value': '7'}, {'count': 2, 'value': '8'}, {'count': 1, 'value': None}]


def deep_sort(obj):
    """
    Recursively sort list or dict nested lists
    """

    if isinstance(obj, dict):
        _sorted = {}
        for key in sorted(obj):
            _sorted[key] = deep_sort(obj[key])

    elif isinstance(obj, list):
        new_list = []
        for val in obj:
            new_list.append(deep_sort(val))
        print(new_list)
        _sorted = sorted(new_list)

    else:
        _sorted = obj

    return _sorted
deep_sort(a)


[{'count': 2, 'value': '10'}, {'count': 2, 'value': '7'}, {'count': 2, 'value': '8'}, {'count': 1, 'value': None}]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-22-6ec57c0f623e> in <module>
     23 
     24     return _sorted
---> 25 deep_sort(a)

<ipython-input-22-6ec57c0f623e> in deep_sort(obj)
     17             new_list.append(deep_sort(val))
     18         print(new_list)
---> 19         _sorted = sorted(new_list)
     20 
     21     else:

TypeError: '<' not supported between instances of 'dict' and 'dict'

In [23]:
sorted([{'count': 2, 'value': '10'}, {'count': 2, 'value': '7'}, {'count': 2, 'value': '8'}, {'count': 1, 'value': None}])


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-23-825707c969c7> in <module>
----> 1 sorted([{'count': 2, 'value': '10'}, {'count': 2, 'value': '7'}, {'count': 2, 'value': '8'}, {'count': 1, 'value': None}])

TypeError: '<' not supported between instances of 'dict' and 'dict'

In [ ]: