I am new to python and exploring to get data from excel using it and found pandas library to get data
I need to get the rates from a HTML table on a website. Table from which the data has to be read Then dump it in an excel file. I am using Python I have used the following code
import pandas as pd
from datetime import datetime
import lxml as lx
import openpyxl as oxl
url = "https://www.example.com"
tables = pd.read_html(url)
table = tables[0]
table.to_excel('output.xlsx')
The dates are in dd mmm yyyy format in the 'Effective Date' column
I would like to convert them to the dd/mm/yyyy format
I used the following code to convert the table
['Effective Date'] = pd.to_datetime(table['Effective Date'],
infer_datetime_format=False, format='%d/%m/%Y', errors='ignore')
but it fails to convert the dates in the column. Could someone head me in some proper direction please.
Here is the complete code
import pandas as pd
import html5lib
import datetime
import locale
import pytz
import lxml as lx
import openpyxl as oxl
url = "https://www.rba.gov.au/statistics/cash-rate/"
tables = pd.read_html(url)
table = tables[0]
table['Effective Date'] = pd.to_datetime(table['Effective Date'],
infer_datetime_format=False, format='%d/%m/%Y', errors='ignore')
table.to_excel('rates.xlsx')
