psrc / urbansim2

3 stars 0 forks source link

Updating orca columns as the wrong orca type(function, local or series) can cause problems. #130

Closed stefancoe closed 6 years ago

stefancoe commented 6 years ago

Using the persons table as an example:

Problems can arise if existing columns are updated in the wrong context. For example, if persons.job_id is updated using the orca.add_column method, then the orca table object will have a local column and a series column both called job_id.

Another example- persons_df is created in memory using persons.to_frame(). Then persons_df is modified and saved back to Orca using orca.add_table('persons', persons_df). Now all of the columns that were added to the orca persons object as functions are also stored as local since .to_frame() gets all columns. To avoid this, either call .local on the orca table object to only bring in the local columns or remove the non-local columns before calling orca.add_table. Columns registered as functions should only be updated by calling the functions that create them.

hanase commented 6 years ago

Good to know! One can also pass an argument to to_frame() that instructs to create the table only from local columns. I believe it's the property .local_columns.

stefancoe commented 6 years ago

As much as possible, now using update_col_from_series to update existing orca tables instead of calling Orca.add_table to overwrite and existing table.