0
MeetingDate = datetime.datetime(2020,5,11)

df = pd.read_csv('request.csv')
dateformatsXpaths = df['dateformat']
MeetingDateXpaths = df['WebCfg_MtgDate_xpath']
urls = df['url']
fcids = df['fcid']
for url in urls:
    driver.get(url) 
    agendaMeetingdateformat = MeetingDate.strftime(df['dateformat'])
    meeting =df['WebCfg_MtgDate_xpath'].replace('*', agendaMeetingdateformat)   
    my_element = driver.find_element_by_xpath(meeting).text 
   if my_element == agendaMeetingdateformat :        
      print('valid Meeting date')  
   else:     
    print('Invalid Meeting date')   
    driver.close()   

I want to convert the given date to the date format that is coming from the df['dateformat'],but its throwing following error

Traceback (most recent call last):
  File "C:\Users\sameer\PycharmProjects\Python\MeetingDateFinder.py", line 32, in <module>
    agendaMeetingdateformat = MeetingDate.strftime(df['datefromat'])
TypeError: strftime() argument 1 must be str, not Series

  • What are you trying to do with `MeetingDate.strftime(df['dateformat'])` ? – Alexandre B. May 09 '20 at 07:15
  • for example df['dateformats']=%c/%e/%Y in the sheet, i want convert today's date into that dateformat.so df['dateformat'] contains a set dateformat provided in the csv ,the date should be converted into that respective dateformat. – Sameer mohd May 09 '20 at 08:37
  • 1
    Here, you're iterating by row in the `dataframe` and using column at the same time. `pandas` have been designed to apply process on whole column. As explained in this [discussion](https://stackoverflow.com/a/55557758/10041823) it's better to avoid `loops` when you can use process on whole columns. To convert a column to `datetime`, use [`pd.to_datetime`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_datetime.html): `df["date_col"] = pd.to_datetime(df["date_col"], format="%c/%e/%Y")` – Alexandre B. May 09 '20 at 08:51
  • thanks man,understood the problem,so what i want to achieve will not be handle by the pandas,i should used database. – Sameer mohd May 09 '20 at 09:19
  • 1
    Most of work on database can by achieved with `pandas`. `pandas` even have a [`query`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.query.html) function that let you perform `SQL` request – Alexandre B. May 09 '20 at 09:21

0 Answers0