So I have the following list of dates
list_dates=[np.datetime64('2018-06-11'),np.datetime64('2018-01-01'),
np.datetime64('2018-03-02'),np.datetime64('2018-03-11'),
np.datetime64('2018-05-19'),np.datetime64('2017-03-19'),
np.datetime64('2018-01-01'),np.datetime64('2017-05-30'),
np.datetime64('2016-08-11'),np.datetime64('2016-06-04')]
I would like to generate a new list only with those dates with the months of january and march.
The desired output would look something like this:
[np.datetime64('2018-01-01'),np.datetime64('2018-03-02'),np.datetime64('2017-03-19'),
np.datetime64('2016-03-11')]
I was thinking I was treating with strings so I did this
dates_selected=[x for x in list_dates if "-03-" in x ]+
[x for x in list_dates if "-01-" in x ]
The problem is that I recieved an ouput indicating that:
TypeError: arguments of type numpy.datetime64 is not iterable
How could I obtain the desired ouput considering I am treating with datetime64 instead of strings?