Link to home
Start Free TrialLog in
Avatar of Hiro 714
Hiro 714

asked on

Python Selenium and Pandas question

When I append, only original df_data appears and unable to append df_data1.
Please advise.

Ticket_List = []
Ticket_Titles = driver.find_elements_by_xpath('//tbody/tr/td[2]/a')
Ticket_Discriptions = driver.find_elements_by_xpath('//tbody/tr/td[3]/a')
Ticket_Status = driver.find_elements_by_xpath('//tbody/tr/td[4]/a')
Ticket_Titles = Ticket_Titles[4:]
Ticket_List = []
for i in range(len(Ticket_Titles)):
    temporary_data={'Number': Ticket_Titles[i].text,
                   'Titles': Ticket_Discriptions[i].text,
                   'Status': Ticket_Status[i].text
                   }
    Ticket_List.append(temporary_data)
   
df_data = pd.DataFrame.from_dict(Ticket_List)
df_data.dtypes
print(df_data)

Open in new window

Ticket_Titles1 = driver.find_elements_by_xpath('//tbody/tr/td[2]/a')
Ticket_Discriptions1 = driver.find_elements_by_xpath('//tbody/tr/td[3]/a')
Ticket_Status1 = driver.find_elements_by_xpath('//tbody/tr/td[4]/a')

Ticket_Titles1 = Ticket_Titles1[4:]

Ticket_Titles.extend(Ticket_Titles1)
Ticket_Discriptions.extend(Ticket_Discriptions1)
Ticket_Status.extend(Ticket_Status1)

Open in new window

Ticket_List1 = []
for i in range(len(Ticket_Titles1)):
    temporary_data1={'Number': Ticket_Titles1[i].text,
                   'Titles': Ticket_Discriptions1[i].text,
                   'Status': Ticket_Status1[i].text
                   }
    Ticket_List1.append(temporary_data1)
   
df_data1 = pd.DataFrame.from_dict(Ticket_List1)

Open in new window

df_data.append(df_data1)

Open in new window


SOLUTION
Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Hiro 714
Hiro 714

ASKER

I would like to use the function. how do i do it?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you.
I tried
df_data=df_data.append(df_data1)

Open in new window

and I get this index. why this is not in order?
User generated image

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you.
I have tried.
df_data.sort_index()

Open in new window

How do I re-index?
User generated image
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry, i thought that is the  number of a row number