@@ -178,7 +178,7 @@ def calculate_wear_stats(data: pd.DataFrame):
178
178
}
179
179
180
180
181
- def exclude_wear_below_days (
181
+ def flag_wear_below_days (
182
182
x : Union [pd .Series , pd .DataFrame ],
183
183
min_wear : str = '12H'
184
184
):
@@ -217,34 +217,34 @@ def exclude_wear_below_days(
217
217
return x
218
218
219
219
220
- def exclude_first_last_days (
220
+ def drop_first_last_days (
221
221
x : Union [pd .Series , pd .DataFrame ],
222
222
first_or_last = 'both'
223
223
):
224
224
"""
225
- Set the values of the first day, last day, or both to NaN in a time series.
225
+ Drop the first day, last day, or both from a time series.
226
226
227
227
Parameters:
228
228
- x (pd.Series or pd.DataFrame): A pandas Series or DataFrame with a DatetimeIndex representing time series data.
229
- - first_or_last (str, optional): A string indicating which days to exclude . Options are 'first', 'last', or 'both'. Default is 'both'.
229
+ - first_or_last (str, optional): A string indicating which days to drop . Options are 'first', 'last', or 'both'. Default is 'both'.
230
230
231
231
Returns:
232
- - pd.Series or pd.DataFrame: A pandas Series or DataFrame with the values of the specified days set to NaN .
232
+ - pd.Series or pd.DataFrame: A pandas Series or DataFrame with the values of the specified days dropped .
233
233
234
234
Example:
235
- # Exclude the first day from the series
236
- series = exclude_first_last_days (series, first_or_last='first')
235
+ # Drop the first day from the series
236
+ series = drop_first_last_days (series, first_or_last='first')
237
237
"""
238
238
if len (x ) == 0 :
239
- print ("No data to exclude " )
239
+ print ("No data to drop " )
240
240
return x
241
241
242
242
if first_or_last == 'first' :
243
- x [x .index .date == x .index .date [0 ]] = np . nan
243
+ x = x [x .index .date != x .index .date [0 ]]
244
244
elif first_or_last == 'last' :
245
- x [x .index .date == x .index .date [- 1 ]] = np . nan
245
+ x = x [x .index .date != x .index .date [- 1 ]]
246
246
elif first_or_last == 'both' :
247
- x [(x .index .date == x .index .date [0 ]) | (x .index .date == x .index .date [- 1 ])] = np . nan
247
+ x = x [(x .index .date != x .index .date [0 ]) & (x .index .date != x .index .date [- 1 ])]
248
248
return x
249
249
250
250
0 commit comments