I'm trying to plot a section of a dataframe. The first column is formatted using the to_datetime method:
all_data['Date_Time_(GMT)'] = pd.to_datetime(all_data['Date_Time_(GMT)'])
...
all_data['Date_Time_(GMT)'].dtype
[out] dtype('<M8[ns]')
The second column is a bunch of intergers:
all_data[new_column].dtype
[out] dtype('int64')
When I try to plot the two columns I get a parser error. Here is the code for the plot:
my_column = 'My Column'
start_date = '2020-08-11 09:28:37'
end_date = '2020-08-11 09:29:28'
new_plot = pd.DataFrame()
new_plot['Date_Time_(GMT)'] = all_data['Date_Time_(GMT)']
new_plot[my_column] = all_data[my_column]
mask = (new_plot['Date_Time_(GMT)'] > start_date) & (new_plot['Date_Time_(GMT)'] <= end_date)
new_plot = new_plot.loc[mask]
df = pd.DataFrame(new_plot, columns=[new_plot['Date_Time_(GMT)'], new_plot[my_column]])
df.plot(x='Date_Time_(GMT)', y=my_column, kind='line' )
plt.show()
Here is the error output:
ParserError Traceback (most recent call last)
pandas\_libs\tslibs\conversion.pyx in pandas._libs.tslibs.conversion._convert_str_to_tsobject()
pandas\_libs\tslibs\parsing.pyx in pandas._libs.tslibs.parsing.parse_datetime_string()
c:\users\user name\appdata\local\programs\python\python38\lib\site-
packages\dateutil\parser\_parser.py in parse(timestr, parserinfo, **kwargs)
1373 else:
-> 1374 return DEFAULTPARSER.parse(timestr, **kwargs)
1375
c:\users\user name\appdata\local\programs\python\python38\lib\site-
packages\dateutil\parser\_parser.py in parse(self, timestr, default, ignoretz, tzinfos, **kwargs)
648 if res is None:
--> 649 raise ParserError("Unknown string format: %s", timestr)
650
ParserError: Unknown string format: Date_Time_(GMT)
Any ideas what completely obvious thing i've done wrong?