Question: Newbie to pandas,

after searching I found pandas is very suitable to make my data divided by parts for further display on charts.

Here is what I do with it:

```
print pd.cut(data_lst, 5).value_counts()

```

the `data_lst` is a list of numbers and above line of code give a pretty neat result like this which is exactly what I need:

```
(-0.513, 25.6]      9
(25.6, 51.2]       43
(51.2, 76.8]      160
(76.8, 102.4]       0
(102.4, 128.0]    302

```

but I just want the result to be a dict as the format of:

```
{
 "(-0.513, 25.6]":9,
 "(25.6, 51.2]":43,
 "(51.2, 76.8]":160,
 "(76.8, 102.4]":0,
 "(102.4, 128.0]":302    
}

```

So that I could save that to the database, but I couldn't find a way to get that result other than print the `value_counts()` out.

Answer: 
After getting `value_counts`, convert the index of the resulting `Series` to `str`.

```
vc = pd.cut(data_lst, 5).value_counts()
vc.index = vc.index.astype(str)
print vc.to_dict()

```

For my toy example, this printed

```
{'(5.0, inf]': 4, '(2.0, 5.0]': 3, '(-inf, 2.0]': 3}

```

which I believe is the format you're after.
save the printed item to a variable and convert that dataframe to dict.

df=( pd.cut(data\_lst, 5).value\_counts())

dict\_n=df.to\_dict()