Skip to content

Instantly share code, notes, and snippets.

@kvnkho
Last active June 6, 2022 07:08
Show Gist options
  • Select an option

  • Save kvnkho/7f2e617c090ba929e682e57e475a0e29 to your computer and use it in GitHub Desktop.

Select an option

Save kvnkho/7f2e617c090ba929e682e57e475a0e29 to your computer and use it in GitHub Desktop.
# case 1: without index
df[df["a"]=="red"]["c"].sum()
# case 2: with "a" as index
idf = df.set_index("a")
idf.loc["red"]["c"].sum()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment