In a df as below:
        id      timestamp               temperature 
27581   27822   2020-01-02 07:53:05.173 19.5    
27582   27823   2020-01-02 07:53:05.273 20.0    
27647   27888   2020-01-02 10:01:46.380 20.5    
27648   27889   2020-01-02 10:01:46.480 21.0    
27649   27890   2020-01-02 10:01:48.463 21.5    
27650   27891   2020-01-02 10:01:48.563 22.0    
27711   27952   2020-01-02 10:32:19.897 21.5    
27712   27953   2020-01-02 10:32:19.997 21.0
27861   28102   2020-01-02 11:34:41.940 21.5    
...
In a for-loop that generate plot, I want to print the weekday of date inside the plot title. date is a datetime.date object. But I incurred some error when formatting the date. I tried something like this, based on this answer:
df['Date'] = df['timestamp'].dt.date     
df.set_index(df['timestamp'], inplace=True)
for date in df['Date'].unique():   
  df_date = df[df['Date'] == date]
  ...
  plt.title(date, date.strftime('%B'))    # I want to print both the date and the corresponding weekday.
The date displays date in the format 2020-01-01 which is fine, but the weekday section returned error:
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-56-6cc9c07f6879> in <module>()
---> 86   plt.title(date, date.strftime('%B'))
     87 
     88   number.append(np.count_nonzero(df2['events'][minLim:maxLim]))
2 frames
/usr/local/lib/python3.6/dist-packages/matplotlib/text.py in update(self, kwargs)
    174         # Update bbox last, as it depends on font properties.
    175         sentinel = object()  # bbox can be None, so use another sentinel.
--> 176         bbox = kwargs.pop("bbox", sentinel)
    177         super().update(kwargs)
    178         if bbox is not sentinel:
AttributeError: 'str' object has no attribute 'pop'
I then tried this, based on this answer:
df['Date'] = df['timestamp'].dt.date     
df.set_index(df['timestamp'], inplace=True)
for date in df['Date'].unique():   
  df_date = df[df['Date'] == date]
  ...
  year, month, day = (int(x) for x in date.split('-'))    
  answer = datetime.date(year, month, day).weekday()
  plt.title(date, answer)
which returned
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-57-03b7529a410a> in <module>()
     82   number = []
     83   ax.autoscale() 
---> 84   year, month, day = (int(x) for x in date.split('-'))
     85   answer = datetime.date(year, month, day).weekday()
     86   plt.title(date, answer)
AttributeError: 'datetime.date' object has no attribute 'split'
Update:
I tried to create the "weekday" column in the date frame for each unique 'date' using:
for date in df['Date'].unique():   
  df_date = df[df['Date'] == date]
  df_date['Date'] = pd.to_datetime(df_date['Date'], errors='coerce')
  df_date['Weekday'] = df_date['Date'].dt.dayofweek  #Add 'Weekday' column.
  print(df_date)
which returned warnings:
/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:7: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
despite the warnings dataframe df_date had been printed.But how should I make it return both date and weekday from the loop(for example "2020-04-02, Thursday")? 
Should I use something like this:
weekday = df_date.loc[date, df_date['Weekday']]
to get the corresponding weekday of date in the loop?
 
    

