Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- df = pd.read_csv(r"C:UsersEddieDownloadspandasDeformation.txt",
- error_bad_lines=False)
- df.dropna(axis=1, how="all", inplace=True)
- suffixes = ["_A", "_B"]
- for suffix in suffixes:
- # Välj ut alla DIG*_*-kolumner och spara i en lista
- dig_cols = [col for col in df.columns if (col.replace("
- ","").startswith("DI") and col.endswith(suffix))]
- # Säkerställ att alla DIG*_*-kolumner är decimaltal
- for col in dig_cols:
- df[col] = df[col].astype(float)
- df[col].replace(0, np.nan, inplace=True)
- df[col].fillna(method="ffill", inplace=True)
- path = r"C:UsersEddieDownloadspandas"
- df.to_csv(os.path.join(path, "Deformation_new.txt"))
Add Comment
Please, Sign In to add comment