Plotting activity times¶
In this example, we show how activity and trip times can be plotted.
In [1]:
Copied!
import os
import pandas as pd
from pam import read
from pam.plot.stats import plot_activity_times, plot_leg_times
import os
import pandas as pd
from pam import read
from pam.plot.stats import plot_activity_times, plot_leg_times
/var/folders/6n/0h9tynqn581fxsytcc863h94tm217b/T/ipykernel_94243/1197232839.py:3: DeprecationWarning: Pyarrow will become a required dependency of pandas in the next major release of pandas (pandas 3.0), (to allow more performant data types, such as the Arrow string type, and better interoperability with other libraries) but was not found to be installed on your system. If this would cause problems for you, please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466 import pandas as pd
In [2]:
Copied!
data_path = os.path.join("data", "example_data")
trips = pd.read_csv(os.path.join(data_path, "example_travel_diaries.csv"))
attributes = pd.read_csv(os.path.join(data_path, "example_attributes.csv"))
attributes = attributes.set_index("pid")
data_path = os.path.join("data", "example_data")
trips = pd.read_csv(os.path.join(data_path, "example_travel_diaries.csv"))
attributes = pd.read_csv(os.path.join(data_path, "example_attributes.csv"))
attributes = attributes.set_index("pid")
In [3]:
Copied!
population = read.load_travel_diary(trips, attributes)
population = read.load_travel_diary(trips, attributes)
Using tour based purpose parser (recommended)
Adding pid->hh mapping to persons_attributes from trips.
Adding home locations to persons attributes using trips attributes.
Using freq of 'None' for all persons.
In [4]:
Copied!
population.random_household().plot()
population.random_household().plot()
In [5]:
Copied!
fig1 = plot_activity_times(population)
fig1 = plot_activity_times(population)
In [6]:
Copied!
fig2 = plot_leg_times(population)
fig2 = plot_leg_times(population)
In [ ]:
Copied!