def h_standardize_das_cdf_cols_names(cols_names: pd.Index) -> pd.Index: """ Convert to standard column names: remove reference to reactor number, convert dasgip v4 names to v5. After converting the dasgip csv to cdf, each cdf has column names with references to the reactor number. This function removes the references so that the column names are the same across each reactor. There is also a difference between the names of some of the columns between different versions of the dasgip control software. The columns names of the files of version 4 are updated to version 5. The highest reactor number supported with this function is 9. Change the regex if higher numbers are needed. Examples -------- (V4) Unit 1.XCO2 1.Out [%] (v5) Unit 1.XCO21.Out [%] (CDF) XCO2.Out [%] (V4) Unit 1.Inoculation Time [] (v5) Unit 1.InoculationTime [] (CDF) InoculationTime [] Parameters ---------- cols_names: pd.Index Original index. Returns ------- pd.Index Index, with standardized column names. """ das_converter_dict = { "Inoculation Time []": "InoculationTime []", "pH.Out []": "pH.Out [%]", "CTR [mM/h]": "CTR.PV [mMol/h]", "RQ []": "RQ.PV []", "AU []": "ODAU.PV []", "CX []": "ODCX.PV []", "Level.PV [µS]": "Lvl.PV [µS]", "MA.PV [g]": "BalA.MPV [g]", "MB.PV [g]": "BalB.MPV [g]", "Torque.PV [mNm]": "N.TStirPV [mNm]", "Offline.A []": "OfflineA.OfflineA []", "Offline.B []": "OfflineB.OfflineB []", "Offline.C []": "OfflineC.OfflineC []", "Offline.D []": "OfflineD.OfflineD []", "OTR [mM/h]": "OTR.PV [mMol/h]", "V.PV [mL]": "V.VPV [mL]" } cols_names = cols_names.str.replace(r"Unit [0-9]\.", "", regex=True) cols_names = cols_names.str.replace(r"\s?[0-9]\.", ".", regex=True) cols_names = cols_names.str.replace(r"[0-9]\s\[", " [", regex=True) cols_names = pd.Index(cols_names.to_series().replace(das_converter_dict)) return cols_names
def test_hasnans_uncached_for_series(): # GH#19700 idx = Index([0, 1]) assert idx.hasnans is False assert "hasnans" in idx._cache ser = idx.to_series() assert ser.hasnans is False assert not hasattr(ser, "_cache") ser.iloc[-1] = np.nan assert ser.hasnans is True assert Series.hasnans.__doc__ == Index.hasnans.__doc__
def test_categorical_repr_unicode(self): # see gh-21002 class County: name = "San Sebastián" state = "PR" def __repr__(self) -> str: return self.name + ", " + self.state cat = Categorical([County() for _ in range(61)]) idx = Index(cat) ser = idx.to_series() repr(ser) str(ser)