AttributeError: 'int' object has no attribute 'astype' in automatic WhatsApp message sender script
The following is an automated WhatsApp message sender script I partially developed. I tried the following script and it worked fine with an excel with 5 numbers in it. However, I tried upscaling it to 1700+ numbers, and I get the following traceback:
Traceback (most recent call last):
File "c:\Users\MSI\Desktop\AutoSenderPY\main.py", line 9, in <module>
cellphone = data.loc[i,'Cellphone'].astype(str)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'astype'*
The script is the following:
import pandas as pd
import webbrowser as web
import pyautogui as pg
import time
data = pd.read_excel("book1.xlsx", sheet_name='sheet1')
for i in range(len(data)):
cellphone = data.loc[i,'Cellphone'].astype(str)
message = "Test Message"
web.open("https://web.whatsapp.com/send?phone=" + cellphone + "&text=" + message)
time.sleep(5.5)
pg.click(1230,964)
time.sleep(1)
pg.press('enter')
time.sleep(2)
pg.hotkey('ctrl', 'w')
time.sleep(1)
Why is that happening, and how can I get it working for those 1700+ numbers?
Try using -
cellphone = str(data.loc[i,'Cellphone'])
I think loc returns a single element of type "numpy.int64", calling the "str" should be enough.