# Access sampler stats and saving burn-in

**URL:** <https://discourse.pymc.io/t/access-sampler-stats-and-saving-burn-in/2582>\
**Category:** Questions\
**Created:** [January 25, 2019, 9:19am UTC](https://discourse.pymc.io/t/access-sampler-stats-and-saving-burn-in/2582 "2019-01-25T09:19:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kappie](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kappie](https://discourse.pymc.io/u/kappie)\
**Post date:** [January 25, 2019, 9:19am UTC](https://discourse.pymc.io/t/access-sampler-stats-and-saving-burn-in/2582/1 "2019-01-25T09:19:03Z")

</div>

I want to save all my samples (including burn-in) as csv file, but also be able to access statistics from trace.stat\_names.

Saving it like  
db = pm.backends.Text(‘MyTrace’)  
trace = pm.sample(10000, [updI], start={‘I’:0.5}, trace=db)

the trace.stat\_names command returns an empty set.

To get around this, I convert trace into a dataframe :  
df = pm.backends.tracetab.trace\_to\_dataframe(trace)  
df.to\_csv(“MyTest.csv”)

However, this will let me loose the samples for the burn-in.  
Is there are way of achieving both, getting stat\_names and burn in?

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [January 25, 2019, 4:20pm UTC](https://discourse.pymc.io/t/access-sampler-stats-and-saving-burn-in/2582/2 "2019-01-25T16:20:31Z")

</div>

Text backend is not very well maintained, so if you want to do I think the most robust way is:

```python
pm.sample(1000, tune=1000, discard_tuned_samples=False)

```
