$\mathrm{d}x$ and $\mathrm{d}y$ aren't numbers, but they are differentials. And differentials can be multiplied by scalars.
And if $\mathrm{d}x$ is nonsingular ($x$ being a so-called "independent variable" guarantees this), then if $z \, \mathrm{d}x = \mathrm{d} y $ has any solutions for $z$, it has a unique solution.
And thus, $z$ really is the ratio of $\mathrm{d}y$ to $\mathrm{d}x$, and it makes sense to say $z = \frac{\mathrm{d}y}{\mathrm{d}x}$.
The usual notation for partial differentiation is... bad. Partial derivatives aren't like ratios at all. Don't treat them like ratios.
More accurately, partial derivatives only become ratios after making a bunch of modifications to the formula being differentiated... and the notation doesn't even tell you what precisely those modifications are supposed to be; you have to infer from context.
For example, if the differential of some bivariate formula is
$$ \mathrm{d}F(x,y) = g(x,y) \mathrm{d} x + h(x,y) \mathrm{d} y $$
then what the notation $\partial F(x,y) / \partial x$ means is:
- First infer that one means to single out $x$ and $y$ as "independent" variables.
- Restrict all the "independent" variables other than $x$ to be constant — in particular, you have $\mathrm{d}y = 0$.
- Simplify the equation to $\mathrm{d}F(x,y) = g(x,y) \mathrm{d} x$.
- Now, there really is a ratio between the two differentials. Define $\partial F(x,y)/\partial x = g(x,y)$ to be that ratio.
Actually, rather than the last two steps, it's more accurate to say that $\partial / \partial x$ means to get to additionally apply to $\mathrm{d}F(x,y)$ the transformation $\mathrm{d}x \mapsto 1$ alongside $\mathrm{d}y \mapsto 0$, but I wanted to give a description that at most resembled a ratio.