This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hello! Thanks for reaching out. There are a few ways to do this. One such could involve building off the MetPy Mondays example, and looping with decadal increments. Here's an approximate example: . . . import numpy as np from matplotlib import cm decades = np.arange(1960, 2020, 10) colors = cm.get_cmap('tab10', len(decades)).colors for year, color in zip(decades, colors): df_temp = df_hu[(datetime(year, 1, 1) <= df_hu['Time']) & (df_hu['Time'] < datetime(year+10, 1, 1))] <insert plotting code from video with our new df_temp, now specify color=color> . . . but there are also potentially other clever Pandas ways to accomplish this task, including using df.query and df.groupby. Look into these! Either way, play around with this, and I hope this at least points you in the right direction. If you have any trouble implementing this, don't hesitate to reach out with further questions. All the best, Drew > I was learning the material in the videos #142 and # 143, and I had a > additional question. What would be the modification to the datetime function > if I wanted to keep the original line : > df_hu = df_hu [df_hu [“Time”]>datetime(2020-##,1,1)] > but I also wanted to separate this prescribed increment by decades within the > selection and color code them. Ticket Details =================== Ticket ID: OAK-610358 Department: Support Python Priority: Low Status: Closed =================== NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.