I have a data set of 7 columns and 2557 rows in a pandas dataframe.
Date Inlet 1 Inlet 2 Inlet 3 Inlet 4 Inlet 5 Inlet 6
01-01-13 0.40 0.41 0.36 10.39 0.37 0.47
02-01-13 -15 0.56 71.90 250.98 90.67 40.89
...
I am trying to replace all negative values with 0 and all values above 192 with 192. I have succeeded in this, but the new dataframe I get is lacking the first row (date). I guess it is left out, because it isn't considered a numeric value? How do I get a new dataframe with the corrected data and still keeping the date column?
I've tried out answers from this question: How to replace negative numbers in Pandas Data Frame by zero
And written following code:
hrt_data = pd.read_csv(hrtdata_file)
num_hrt = hrt_data._get_numeric_data()
num_hrt[num_hrt < 0] = 0
num_hrt[num_hrt > 192] = 192