And here are a couple ways I tried to solve it but didn’t quite get it. I am usi
ID: 3915883 • Letter: A
Question
And here are a couple ways I tried to solve it but didn’t quite get it. I am using the package pandas in python to work with and read and write to excel spreadsheets. I have created 2 different dataframes (df1 and d12) that have cells that are all of the data type string. df1 has over 94,000 rows. There are many cells in each column of df1 that were "Nan'and I have converted to to a string that says "Empty. df2 has over 9000 rows. Every row in "Dept Nor and "Dept Desc HR contains an accurate string value. Only some rows have values other than the string Empty in the last 2 columns of d12. The Department column in df1 has many cells containing names with only words. The rows of the "Department column in di1 that I am interested in identifying are the ones that contain any of the department numbers that are found in df2 in the "Dept.Nbt column. Example of dataframe1-dfi btitde DepartmentTepartment Function Accounts Payable Accounting pty Cyber Security GASecurity&Compliance; Data Security ty Merch04-1854 Empty Empty y WH-1925 Empty Montreal-10 Empty mpty capadal 05-4325 Empty Emnt Example of dataframe2- df2 Technology Flnance Tech Campus Outreach 10 1854 Community Relations 1925 H 4325 Global People 9237 International Tech So I want to iterate through all rows of the "Department Column" of df1 to search for dept numbers that appear in the Rept.Nbr.column of df2. In this example, I would want my code to Dept.Desc.HR column of df2 and write "Community Relations" in the "True Department appears in the Department column. When the iteration reaches "Montreal 10", I would want find 1854 in the "Department" column of dfi and map that numberto the associated cell in the column of dfi (to same row that contains substring "1854 In Department column. And it would also write "Human Resources" to True Department column in same row substring "1925" my code to write "Campus Outreach" to the TrueDepartment column of df1 since if there is a value in Dept Dess AD of df2, this will serve as an override to what is in column "Dept Desc HR" of df2. I have become familiar enough with pandas to read excel files (-xisd) and make the data frames and change datatypes within the data frame for iteration purposes view the data frames, but can't figure out the most effective and efficient way to structure this code to accomplish this goal. I had to edit this question just now because [ realized ileft outExplanation / Answer
install the software package pyxl in python. Then follow the commands: