I have been having the same problem. I think it doesn’t like pandas. As I have tried to execute my script with my pandas code, and without out, it works executing the code without. Which is annoying as most of my code is written with pandas. Hopefully they build some sort of extension for it.
If you managed to sort it out please let me know. Thanks
It has nothing to do with the pandas library. Either the pandas library is not installed on your 32-Bit instance of Python (unlikely) or you are referencing a path incorrectly.
You can’t use short paths in Python like ‘Data/somefile.csv’. You have to use the full path or pass the full path. You can’t use a working directory variable in your Python script because the wrong path will be used.
I got the following code to execute successfully:
import pandas as pd
df = pd.read_excel(r'C:\Users\******\PycharmProjects\sandbox\Data\*****.xlsx')
for row in df.iterrows():
print(row)
Can you share your entire script or possibly the problematic section?
ah ok, just made the changes you suggested to my script for both reading and writing files within pandas but still get the same error. Attached is my script, the commented out lines is what I had before.
import pandas as pd
import datetime
import os
def read_and_return_excel():
week_num = 38
poa_excel_name = 'POA W' + str(week_num) + '.xlsx'
#df_poa = pd.read_excel(os.getcwd() + '\\python_code\\email_attachments\\' + poa_excel_name)
#df_utwo = pd.read_excel(os.getcwd() + '\\python_code\\email_attachments\\U2000 Name and Site Name.xlsx')
df_poa = pd.read_excel(r'C:\Users\xxx\Documents\UiPath\test\python_code\\email_attachments\\' + poa_excel_name)
df_utwo = pd.read_excel(r'C:\Users\xxx\Documents\UiPath\test\python_code\\email_attachments\\U2000 Name and Site Name.xlsx')
return df_poa, df_utwo
def check_utwo_in_codigo(dfs):
df_poa, df_utwo = dfs
df_all = df_utwo.merge(df_poa, on='CODIGO_SITE')
df_filtered = df_all[
[
'CODIGO_SITE',
'U2000 Name',
'Site Name 2G',
'Site Name 3G',
'Site Name 4G'
]
].copy()
return df_filtered
def sort_ne_list(ne_df_unsorted):
df_ne = pd.DataFrame()
for idx, row in ne_df_unsorted.iterrows():
utwo_list = [row['U2000 Name']] * 3
df_dict = {
'NE Name': [
row['Site Name 2G'],
row['Site Name 3G'],
row['Site Name 4G']
],
'U2000' : utwo_list
}
df_ne = df_ne.append(pd.DataFrame(df_dict))
df_eone = df_ne.loc[df_ne['U2000'] == 'ATAE1']
df_etwo = df_ne.loc[df_ne['U2000'] == 'ATAE2']
df_ethree = df_ne.loc[df_ne['U2000'] == 'ATAE3']
#df_eone.to_csv('atae1.csv', index=False)
#df_etwo.to_csv('atae2.csv', index=False)
#df_ethree.to_csv('atae3.csv', index=False)
df_eone.to_csv('C:\Users\xxx\Documents\UiPath\test\python_code\\atae1.csv', index=False)
df_etwo.to_csv('C:\Users\xxx\Documents\UiPath\test\python_code\\atae2.csv', index=False)
df_ethree.to_csv('C:\Users\xxx\Documents\UiPath\test\python_code\\atae3.csv', index=False)
excel_dfs = read_and_return_excel()
ne_df_unsorted = check_utwo_in_codigo(excel_dfs)
sort_ne_list(ne_df_unsorted)
Did you double check that this works on its own? You used ‘\’ and ‘\\’ in the path names with the r’’ literal string flag.
You have to either use ‘\’ WITHOUT “r” or '' WITH “r” like so: 'C:\\Users\\xxx\\Documents\\UiPath\\test\\python_code\\email_attachments\\U2000 Name and Site Name.xlsx'
OR
r'C:\Users\xxx\Documents\UiPath\test\python_code\email_attachments\U2000 Name and Site Name.xlsx'
I am beginning to think is this worth it! As originally I needed to finish it quickly so I just run a recording of my opening conda prompt and running the file. But as now refactoring it I thought it would be good to sort this out, as my initial problem was the 64bit so changed that, but now it seems to not like pandas
I can’t decide for you if this is worth your time, but python is highly useful tool and can be easily incorporated with UiPath once you get around these kinks.
I’m attempting to run your code on my machine now if you can wait.
In the meantime, I would try removing all of your comments from the current script as ‘\’ may be causing errors.
I just ran this same script and it worked fine for me.
Unfortunately, the best I can say is to re-re-check your environment, as I believe the correct Anaconda installation or Python interpreter is NOT being referenced.
Any chance you could share your .xaml file with this sequence? I’m out of ideas if you can’t even get “import” to work.
Because you are using miniconda, you need to make sure that all packages you are using are installed manually in the 32-Bit instance of the miniconda installation.
Additionally, if this is something that you installed recently, you need to make sure you are using Python 3.6 and not Python 3.7.
I just did a fresh install of miniconda to test my theory, and pandas was NOT installed automatically.
If you install pandas for the correct instance, your script should work.
This is originally what I have done. I downloaded the 32-bit miniconda, created a virtual env with python 3.6 and installed pandas to the specific environment. But if you look at the attachment. It says my python is version is 3.6 within my virtual env, The conda info shows that it is 32 bit but it says it is python 3.7 not sure how this is possible?