# enginetotalhoursofoperationj1939 - SPN 247

## High-Level Explanation - SPN 247

This signal is a count of the number of hours that the engine has been operating for. This signal is a floating point number and the resolution is accurate to 0.05 hours (3 minutes).

## Enables

This signal, similar to odometer, is strictly increasing and can be used to determine the total number of hours that an engine has operated. Further, this signal can be used to determine how many hours a vehicle has operated during any subset of time for which there are recorded values of `enginetotalhoursofoperationj1939`.&#x20;

For example, to determine how many hours a vehicle was operating per day, the following code can be used. Note that this code is also robust to missing data between days as the difference in engine operating hours from the end of the each day to the start of the next day are ignored (e.g. if data is received on day 1, day 2, day 5, day 6, the hours that the vehicle was operating on day 3 and day 4 would not be counted in the hours operating on day 5).

{% code overflow="wrap" lineNumbers="true" %}

```python
gdf['year_month_day'] = gdf['timestamp'].map(lambda x: x.strftime('%Y_%m_%d'))

gdf['engine_hours_operation_diff'] = gdf['enginetotalhoursofoperationj1939'].ffill().bfill().diff().fillna(0)

temp = gdf.dropna(subset = 'enginetotalhoursofoperationj1939').copy(deep = True)
temp = temp.loc[~temp['timestamp'].isin(temp.groupby('year_month_day').first()['timestamp'].tolist())]

day_data['engine_hours_operation_sum'] = temp.groupby('year_month_day')['engine_hours_operation_diff'].sum()
```

{% endcode %}

## Enabled By

This signal is only available on vehicles with j1939 data, which is found on heavy trucks.

## Known Quirks

## Visualizations with Explanations

<figure><img src="https://3212476574-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Foh9c3w7RI0Bl5tVCxcyz%2Fuploads%2FvW7BXRuex26SyEChJtBf%2Fimage.png?alt=media&#x26;token=af7c2806-d0dc-4919-a1c7-2d12153d0ee6" alt=""><figcaption><p>A plot of the monotonically increasing <code>enginetotalhoursofoperationj1939</code> signal</p></figcaption></figure>
