- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.1k
Description
Describe the bug
Using the DataCollector indexes for the model step of the DataFrames coming from .get_model_vars_dataframe() and .get_agent_vars_dataframe() are different if the DataCollector is called after the schedule.step(). I.e., if the model's step function looks like:
def step(self):
    self.datacollector.collect(self)
    self.schedule.step()
The "Step" index of the dataframe returned by .get_agent_vars_dataframe() will start with 1. In contrast, the index of the dataframe from get_model_vars_dataframe() will start with 0. This makes it diificult to merge frames in result processing.
Expected behavior
The indexes referring to the model step should be consistent. In the setting above, I would expect all step index starting at 1 (since the model has made one step before the report).
To Reproduce
The behavior can be reproduce by altering the step function to the code above in the MoneyModel in the Collecting data section of the introductory tutorial
Additional context
I am a newbie to Mesa, so I can only guess on the reasons. My first guess would be that the different index are caused by the different treatment of model and agent_reporters in the collect function of the DataCollector. The model_reporter seems to be list-based and the index is implicitly derived leading to the index starting at zero independently whether the collector is called before or after execution of the step. In contrast, the agent_reporters use the Scheduelers step property which seems to be advanced by one if the collector is called after execution of the step.