Created
July 23, 2015 13:20
-
-
Save geogradient/072d05784f44aab97d6b to your computer and use it in GitHub Desktop.
Example of using Pandas for renaming columns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
# 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