question: D3 Q3
This commit is contained in:
parent
b10d5f623e
commit
563be46da6
|
|
@ -36,7 +36,7 @@ else:
|
|||
|
||||
|
||||
################################################################################
|
||||
################## Question 2 ##################################################
|
||||
################## Question 3 ##################################################
|
||||
################################################################################
|
||||
|
||||
# Construct a dataframe and pivot it to obtain a dataframe with a column per unit, and a row per timestamp.
|
||||
|
|
@ -46,12 +46,22 @@ df_pivot = df.pivot_table(values='value', columns='unit', index='time')
|
|||
df_resampled = df_pivot.resample('s').mean()
|
||||
df_resampled.interpolate(method='linear', inplace=True)
|
||||
df_resampled = pd.DataFrame(df_resampled)
|
||||
df_gaia = df_resampled['gaia_p']
|
||||
df_gaia_diffs = df_gaia.diff()
|
||||
gaia_min, gaia_max = df_gaia.min(), df_gaia.max()
|
||||
diff_min, diff_max = df_gaia_diffs.min(), df_gaia_diffs.max()
|
||||
|
||||
print(f'{gaia_min=}, {gaia_max=}')
|
||||
print(f'{diff_min=}, {diff_max=}')
|
||||
|
||||
# Plot the data. Note, that the data will mostly not be plotted with lines.
|
||||
plt.ion() # Turn interactive mode on
|
||||
plt.figure()
|
||||
ax1 = plt.subplot(211) # Make two separate figures
|
||||
ax2 = plt.subplot(212)
|
||||
df_resampled[[c for c in df_resampled.columns if c.endswith('_p')]].plot(marker='.', ax=ax1, linewidth=3)
|
||||
df_resampled[[c for c in df_resampled.columns if c.endswith('_q')]].plot(marker='.', ax=ax2, linewidth=3)
|
||||
ax1, ax2 = plt.subplot(211), plt.subplot(212)
|
||||
df_gaia.plot(marker='.', ax=ax1, linewidth=3)
|
||||
ax1.hlines([gaia_min, gaia_max], df_gaia.index.min(), df_gaia.index.max(), color='r')
|
||||
df_gaia_diffs.plot(marker='.', ax=ax2, linewidth=3)
|
||||
plt.show(block=True)
|
||||
|
||||
## gaia_min=0.62, gaia_max=7.085
|
||||
## diff_min=-1.963, diff_max=1.3210000000000002
|
||||
|
|
|
|||
Loading…
Reference in New Issue