Skip to content

Instantly share code, notes, and snippets.

@Drvanon
Created July 31, 2021 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Drvanon/0720fb6acc240ab15c680486b9d6e79e to your computer and use it in GitHub Desktop.
Save Drvanon/0720fb6acc240ab15c680486b9d6e79e to your computer and use it in GitHub Desktop.
/export/home/ccprakt3/miniconda3/lib/python3.9/site-packages/pandas/core/frame.py:3607: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
self._set_item(key, value)
rows = [{'a': 1, 'b': 2}, {'a':3, 'b':4}]
df = pd.DataFrame(rows)
df = df.set_index(['mutant', 'method', 'state id', 'transition id'])
df.sort_index(level=['mutant','method', 'state id', 'transition id'], inplace=True)
orb_map = np.loadtxt('../F/BLYP-B3LYP-orbital-overlap.txt', skiprows=1)
df1 = df.loc[("NH2", "BLYP"), :]
df2 = df.loc[("NH2", "B3LYP"), :]
df1.loc[:, "mapped occupied"] = df1.loc[:,"occupied"].map(lambda o: int(orb_map[orb_map == o][1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment