I am perplexed as to why I can't use scatter with my matplotlib dataframe. I am trying to plot elapsed time as a function of voltage. Whenever I try with plt.plot it works, but I need it as a scatter plot. My data looks like this
filtered_data['Elapsed Time']
5 0 days 00:00:00.002000
6 0 days 00:00:00.003000
7 0 days 00:00:00.003000
10 0 days 00:00:00.005000
11 0 days 00:00:00.005000
15 0 days 00:00:00.007000
17 0 days 00:00:00.008000
20 0 days 00:00:00.010000
21 0 days 00:00:00.010000
24 0 days 00:00:00.011000
27 0 days 00:00:00.013000
31 0 days 00:00:00.015000
35 0 days 00:00:00.017000
36 0 days 00:00:00.018000
37 0 days 00:00:00.018000
38 0 days 00:00:00.019000
40 0 days 00:00:00.020000
41 0 days 00:00:00.020000
42 0 days 00:00:00.021000
43 0 days 00:00:00.021000
47 0 days 00:00:00.023000
49 0 days 00:00:00.024000
50 0 days 00:00:00.025000
54 0 days 00:00:00.026000
55 0 days 00:00:00.027000
...
115 0 days 00:00:00.057000
116 0 days 00:00:00.058000
117 0 days 00:00:00.058000
118 0 days 00:00:00.059000
Name: Elapsed Time, dtype: timedelta64[ms]
similarly my voltage data filtered_data['Voltage']:
5 11.4143
6 11.4039
7 11.3956
10 11.4122
11 11.4060
15 11.4122
17 11.4060
20 11.4184
21 11.4143
24 11.4039
27 11.4060
31 11.3936
35 11.4143
36 11.3894
37 11.4184
38 11.4019
40 11.3936
41 11.4102
42 11.4164
43 11.4081
47 11.3977
49 11.4122
50 11.4164
54 11.4122
55 11.4081
...
115 11.4164
116 11.3936
117 11.4495
118 11.4143
Name: Voltage , dtype: float64
However, when I try to plot it either using:
plt.scatter(filtered_data['Elapsed Time'], filtered_data['Voltage'])
or
filtered_data.plot(kind='scatter',x='Elapsed Time'',y='Voltage')
(in this case the Elapsed Time and Voltage doesn't even fill in)
or using
filtered_data.plot.scatter(x='Elapsed Time'',y='Voltage')
Either way I try it I always get this error:
TypeError: The DType could not be promoted by . This means that no common DType exists for the given inputs. For example they cannot be stored in a single array unless the dtype is object
. The full list of DTypes is: (, )
I listed what I tried above, I was expecting a scatter plot of elapsed time versus voltage