[Python] Type error: cannot substract DateTimeArray from ndarray

Discussão em 'Python' iniciado por Stack, Março 20, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to find the difference between 2 time and dates and result to be in a new column from a csv file(df).. Appreciate any help here..

    elif file_path.endswith(".csv"):
    df = pd.read_csv(file_path)
    break
    else:
    df = pd.read_excel(file_path, engine="openpyxl")
    break

    # Transformations
    df["open_time"] = np.where(
    (
    pd.to_datetime(df["Date/Time Opened"]).dt.date
    + pd.DateOffset(hours=17)
    - pd.to_datetime(df["Date/Time Opened"])
    ).dt.total_seconds()

    Continue reading...

Compartilhe esta Página