Let us consider a point P in cylindrical polar co-ordinate system, having cylindrical co-ordinates (\rho,\ \phi,\ z) . The cartesian co-ordinates of the point P is (x,\ y,\ z) . Let’s draw a vertical line PQ on the X-Y plane, which is parallel to the z-axis, as shown in Fig.1.

OQ is represented by \rho , which makes an angle \phi with the X-axis.
From Fig. 1 we can write,
x=\rho\ \cos\phi
y=\rho\ \sin\phi
and z=z
If \vec{r} be the position vector with respect to the origin O, then we can write \vec{r}=x\ \hat{i}+y\ \hat{j}+z\ \hat{k}\tag{1}
where, \hat{i} , \hat{j} and \hat{k} is the unit vector along the X-axis, Y-axis and Z-axis respectively.
Now, equation (1) can be written as,
\vec{r}=\rho\ \cos\phi\ \hat{i}+\rho\ \sin\phi\ \hat{j}+z\ \hat{k}\tag{2}
Let, \hat{\rho} be the unit vector along the direction of increasing \rho , then we can write,
\displaystyle{\hat{\rho}=\frac{\frac{\delta{\vec{r}}}{\delta{\rho}}}{|\frac{\delta{\vec{r}}}{\delta{\rho}}|}}
Now, \frac{\delta{\vec{r}}}{\delta{\rho}}=\cos\phi\ \hat{i}+\sin\phi\ \hat{j}
Therefore, \hat{\rho}=\cos\phi\ \hat{i}+ \sin\phi\ \hat{j}\tag{i}
Let, \hat{\phi} be the unit vector along the direction of increasing \phi then we can write,
\displaystyle{\hat{\phi}=\frac{\frac{\delta{\vec{r}}}{\delta{\phi}}}{|\frac{\delta{\vec{r}}}{\delta{\phi}}|}}Now, \frac{\delta{\vec{r}}}{\delta{\phi}}=-\rho\ \sin\phi\ \hat{i}+\rho\ \cos\phi\ \hat{j}
and |\frac{\delta{\vec{r}}}{\delta{\phi}}|= \sqrt{{\rho}^2\ \sin^2\phi+{\rho}^2\ \cos^2\phi}=\rho
Therefore, \hat{\phi}=\displaystyle{\frac{\frac{\delta{\vec{r}}}{\delta{\phi}}}{|\frac{\delta{\vec{r}}}{\delta{\phi}}|}}=-\sin\phi\ \hat{i}+\cos\phi\ \hat{j}\tag{ii}
Let, \hat{z} be the unit vector along the direction of increasing z , then we can write,
\displaystyle{\hat{z}=\frac{\frac{\delta{\vec{r}}}{\delta{z}}}{|\frac{\delta{\vec{r}}}{\delta{z}}|}}Now, \displaystyle{\frac{\delta{\vec{r}}}{\delta{z}}=\hat{k}}
Therefore, \hat{z}=\hat{k}\tag{iii}
So, the equations (i), (ii) and (iii) represent the unit vectrors in cylindrical polar co-ordinate system in terms of the unit vectors in spherical polar co-ordinate system.