Computing the sky coordinates using astropy

Hello Astropy community,

I need your help with an error I have been receiving while trying to obtain the sky coordinates using astropy module in python.

The code looks like the following,

c = coord.SkyCoord(ra = u.Quantity(gaia_data["ra"] * u.deg),
               dec = u.Quantity(gaia_data["dec"] * u.deg),
               distance = u.Quantity(gaia_data["distance"] * u.pc),
               pm_ra_cosdec = u.Quantity(gaia_data["pmra"] * u.mas/u.year),
               pm_dec = u.Quantity(gaia_data["pmdec"] * u.mas/u.year),
               radial_velocity = u.Quantity(gaia_data["rv"] * u.km/u.s))

I have read the queried data from Gaia DR3 into a pandas dataframe which is why I am converting the individual columns to quantity to ensure correctness while calculating the coordinates. The thing that surprises me the most is that the code works perfectly fine when I run it on a smaller dataset from Gaia DR3 (about 40k objects), the error pops up when I try doing it for the actual dataset (about 2.1M stars). So, may be the actual dataset has some stray data though that is unlikely because I have queried the database in such a way that the positional data does not have null values.

The error message looks like the following,

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-17-e9a930de875e> in <module>
      4                    pm_ra_cosdec = u.Quantity(gaia_data["pmra"] * u.mas/u.year),
      5                    pm_dec = u.Quantity(gaia_data["pmdec"] * u.mas/u.year),
----> 6                    radial_velocity = u.Quantity(gaia_data["rv"] * u.km/u.s))

~/.local/lib/python3.6/site-packages/astropy/coordinates/sky_coordinate.py in __init__(self, copy, *args, **kwargs)
    329             # Finally make the internal coordinate object.
    330             frame_kwargs.update(components)
--> 331             self._sky_coord_frame = frame_cls(copy=copy, **frame_kwargs)
    332 
    333             if not self._sky_coord_frame.has_data:

~/.local/lib/python3.6/site-packages/astropy/coordinates/baseframe.py in __init__(self, copy, representation_type, differential_type, *args, **kwargs)
    581                     if not current_diff_unit.is_equivalent(current_repr_unit / u.s):
    582                         raise ValueError(
--> 583                             "Differential data units are not compatible with"
    584                             "time-derivative of representation data units")
    585             self._data = representation_data.with_differentials(

ValueError: Differential data units are not compatible withtime-derivative of representation data units

I do not understand the error message and I did not find any relevant source explaining what this means and how do I get rid of it?

Did anyone encounter this before? What is the solution?

This may need some further testing to check if it is the radial_velocity input, as it appears from the first part of the traceback.
But first you should note that with your Python version you can only have a very old version of Astropy installed; even our current Long Term Support release requires at least 3.7. If possible you should update your Python installation to at least 3.9, better 3.10 or 3.11, and then get the latest Astropy 5.2.1. It might be that the problem is already resolved there.