Skip to content

Splatalogue query error #29

Open
Open
@laserkelvin

Description

@laserkelvin

Seems like pandas in the latest versions raises an error when trying to merge the measured and calcualted frequency columns when astroquery returns the Splatalogue query.

The error stack:

ValueError                                Traceback (most recent call last)
<ipython-input-30-ec137040be31> in <module>
      1 # this runs through splatalogue
----> 2 session.process_splatalogue(auto=True)

~\anaconda3\lib\site-packages\pyspectools\spectra\assignment.py in process_splatalogue(self, auto, progressbar)
   2211             else:
   2212                 width = self.session.freq_prox * frequency
-> 2213             splat_df = analysis.search_center_frequency(frequency, width=width)
   2214             if splat_df is not None:
   2215                 # Filter out lines that are way too unlikely on grounds of temperature

~\anaconda3\lib\site-packages\pyspectools\spectra\analysis.py in search_center_frequency(frequency, width)
    294         if splat_df.isna().any().sum():
    295             # Replace missing experimental data with calculated
--> 296             splat_df["Frequency"].fillna(splat_df["Freq-GHz"], inplace=True)
    297         # Convert to MHz
    298         splat_df["Frequency"] *= 1000.

~\anaconda3\lib\site-packages\pandas\core\series.py in fillna(self, value, method, axis, inplace, limit, downcast)
   4461         downcast=None,
   4462     ) -> Optional["Series"]:
-> 4463         return super().fillna(
   4464             value=value,
   4465             method=method,

~\anaconda3\lib\site-packages\pandas\core\generic.py in fillna(self, value, method, axis, inplace, limit, downcast)
   6406                     )
   6407 
-> 6408                 new_data = self._mgr.fillna(
   6409                     value=value, limit=limit, inplace=inplace, downcast=downcast
   6410                 )

~\anaconda3\lib\site-packages\pandas\core\internals\managers.py in fillna(self, value, limit, inplace, downcast)
    619 
    620     def fillna(self, value, limit, inplace: bool, downcast) -> "BlockManager":
--> 621         return self.apply(
    622             "fillna", value=value, limit=limit, inplace=inplace, downcast=downcast
    623         )

~\anaconda3\lib\site-packages\pandas\core\internals\managers.py in apply(self, f, align_keys, ignore_failures, **kwargs)
    425                     applied = b.apply(f, **kwargs)
    426                 else:
--> 427                     applied = getattr(b, f)(**kwargs)
    428             except (TypeError, NotImplementedError):
    429                 if not ignore_failures:

~\anaconda3\lib\site-packages\pandas\core\internals\blocks.py in fillna(self, value, limit, inplace, downcast)
    441         if self._can_hold_element(value):
    442             nb = self if inplace else self.copy()
--> 443             nb._putmask_simple(mask, value)
    444             # TODO: should be nb._maybe_downcast?
    445             return self._maybe_downcast([nb], downcast)

~\anaconda3\lib\site-packages\pandas\core\internals\blocks.py in _putmask_simple(self, mask, value)
   1067         else:
   1068             # GH#37833 np.putmask is more performant than __setitem__
-> 1069             np.putmask(values, mask, value)
   1070 
   1071     def putmask(

<__array_function__ internals> in putmask(*args, **kwargs)

~\anaconda3\lib\site-packages\pandas\core\arrays\masked.py in __array__(self, dtype)
    237         We return an object array here to preserve our scalar values
    238         """
--> 239         return self.to_numpy(dtype=dtype)
    240 
    241     def __arrow_array__(self, type=None):

~\anaconda3\lib\site-packages\pandas\core\arrays\masked.py in to_numpy(self, dtype, copy, na_value)
    218                 and na_value is libmissing.NA
    219             ):
--> 220                 raise ValueError(
    221                     f"cannot convert to '{dtype}'-dtype NumPy array "
    222                     "with missing values. Specify an appropriate 'na_value' "

ValueError: cannot convert to 'float64'-dtype NumPy array with missing values. Specify an appropriate 'na_value' for this dtype.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions