Python: how to convert the first dimension of a netcdf file to a dataframe?

Converting an xarray dataset to dataframe is fairly straightforward, as there is a built-in method:

df = ds.to_dataframe()