load rr for constanza

mail@pastecode.io avatar
unknown
python
a month ago
503 B
3
Indexable
Never
import pandas as pd

# define filepath
filepath = "/Users/hheinrichs/Downloads/RR-Interval - 112.txt"

# load in relevant part of CSV
body = pd.read_csv(
    filepath, skiprows=5, sep=";", header=None, names=["datetime", "rr", "sleep"]
)

# change datatype of columns
body["datetime"] = pd.to_datetime(body["datetime"], format="%d.%m.%Y %H:%M:%S,%f")
body["rr"] = pd.to_numeric(body["rr"], errors="coerce")
body["rr"] = body["rr"].astype("Int64")
body["sleep"] = body["sleep"] == " Sleep"

# visualize

Leave a Comment