I have data for rain measurements and water level measurements. But with different date and time values. Let's say I want to compare the data by visualizing it in a subplot figure at the exact same time. I have tried to do it myself with to diffent dataframes, as seen in the figure: Rain and water level measurements
As seen, the time is shifted in both figures, making it hard to compare the "peaks" according to the same time.
Is there a way of comparing it by using Pandas DataFrame? I have tried it myself, using the following code:
import pandas as pd
import matplotlib.pyplot as plt
import pickle
wb = pickle.load(open("data.p","rb"))
rain_period = wb[0]
flow_knudmose = wb[1]
periods = [['20170224','20170819','20170906'],
['20170308','20170826','20170917']]
# Period 1
rain_1 = rain_period.loc[(rain_period['Time'] >= periods[0][0]) &(rain_period['Time'] <= periods[1][0]) ]
rain_1.sort_values('Time',ascending=True,inplace=True)
water_1 = flow_knudmose.loc[(flow_knudmose['Time'] >= periods[0][0]) & (flow_knudmose['Time'] <= periods[1][0]) ]
water_1.sort_values('Time',ascending=True,inplace=True)
fig,axes = plt.subplots(nrows=2,ncols=1)
rain_1.plot(color='b',ax = axes[0], x='Time')
water_1.plot(color='r',ax = axes[1], x='Time')
plt.show()
This code made the figure I have attached. You can get the data.p
pickle here
Thanks in advance!