Let X be a one dimensional positive recurrent diffusion continuously observed on [0,t] . We consider a non parametric estimator of the drift function on a given interval. Our estimator, obtained using a penalized least square approach, belongs to a finite dimensional functional space, whose dimension is selected according to the data. The non-asymptotic risk-bound reaches the minimax optimal rate of convergence when t → ∞. The main point of our work is that we do not suppose the process to be in stationary regime neither to be exponentially β-mixing. This is possible thanks to the use of a new polynomial inequality in the ergodic theorem [E. Löcherbach, D. Loukianova and O. Loukianov, Ann. Inst. H. Poincaré Probab. Statist. 47 (2011) 425–449].