Skip to content

Commit

Permalink
Do not use .loc when assigning new values (chained indexing).
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdekoning committed Aug 22, 2019
1 parent b5093e3 commit c45ce1f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions activity_browser/app/bwutils/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def add_metadata(self, db_names_list):

# In a new 'biosphere3' database, some categories values are lists
if 'categories' in df_temp:
df_temp.loc[:, 'categories'] = df_temp['categories'].apply(
df_temp['categories'] = df_temp['categories'].apply(
lambda x: tuple(x) if isinstance(x, list) else x)

dfs.append(df_temp)
Expand Down Expand Up @@ -116,8 +116,8 @@ def update_metadata(self, key):
if key in self.dataframe.index: # Situation 2: activity has been modified (metadata needs to be updated)
print('Updating activity in metadata: ', act, key)
for col in self.dataframe.columns:
self.dataframe.loc[key][col] = act.get(col, '')
self.dataframe.loc[key]['key'] = act.key
self.dataframe.at[key, col] = act.get(col, '')
self.dataframe.at[key, 'key'] = act.key

else: # Situation 3: Activity has been added to database (metadata needs to be generated)
print('Adding activity to metadata:', act, key)
Expand Down

0 comments on commit c45ce1f

Please sign in to comment.