add_states function

Add states to a dataset based on groups and start/end times