Skip to content

Instantly share code, notes, and snippets.

@geogradient
Created July 23, 2015 13:20
Show Gist options
  • Save geogradient/072d05784f44aab97d6b to your computer and use it in GitHub Desktop.
Save geogradient/072d05784f44aab97d6b to your computer and use it in GitHub Desktop.
Example of using Pandas for renaming columns
# ...
# The nutrients dictionary holds a panda data frame with columns week, and "PO4_mgP_m3" or "DIN_mgN_m3".
# for simplicity I rename the columns holding the values as value.
for station in nutrients.keys():
for year in nutrients[station].keys():
nutrients[station][year]["PO4"].rename(columns={"PO4_mgP_m3":'value'}, inplace=True)
nutrients[station][year]["DIN"].rename(columns={"DIN_mgN_m3":'value'}, inplace=True)
# Example of use
nutrients["B1"][2010]["PO4"].keys()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment