excel

python write a list to multiple columns in excel

python write a list to multiple columns in excel Question: I am trying to write many columns in excel. I have a list let’s say as below list1=[1,2,3,4,5] the other list will be like list2=[‘a’,’b’,’c’] I will have many different sized(length) lists which is why I cannot create dataframe in pandas and write it. list3=[‘1a’,’2b’,’3c’,’4d’] …

Total answers: 1

Xlsm file Python

Xlsm file Python Question: I want to open an .xlsm file with openpyxl library. When I tried to open it, it gives me the IndexError: index out of range. I also observed if I delete all the hidden worksheets in the file before running the code it will be OK. Can you help me? Because …

Total answers: 2

Python: How to preserve leading zeroes when reading in pandas a #0000000000 formatted excel column

Python: How to preserve leading zeroes when reading in pandas a #0000000000 formatted excel column Question: I have an Excel file with a column with custom formatting #0000000000. If I read it into a pandas data frame with either of these three commands pd.read_excel("Formatted_File.xlsx", dtype=str) or pd.read_excel("Formatted_File.xlsx", dtype="object") or just pd.read_excel("Formatted_File.xlsx") I get a data …

Total answers: 1

pandas combine specific excel sheets into one

pandas combine specific excel sheets into one Question: I have an excel sheet named output.xlsx with multiple sheets in it. Example, the sheets within it are named as P1,P2,P3,P4 I would like to do the below a) Combine sheet P1 and sheet P2 into one single sheet name it as P1&P2 b) retain the P3 …

Total answers: 1

pandas groupby, split df and rename multiple sheets

pandas groupby, split df and rename multiple sheets Question: I have a dataframe like as below import numpy as np import pandas as pd from numpy.random import default_rng rng = default_rng(100) cdf = pd.DataFrame({‘Id’:[1,2,3,4,5], ‘customer’: rng.choice(list(‘ACD’),size=(5)), ‘segment’: rng.choice(list(‘PQRS’),size=(5)), ‘manager’: rng.choice(list(‘QWER’),size=(5)), ‘dumma’: rng.choice((1234),size=(5)), ‘damma’: rng.choice((1234),size=(5)) }) I would like to do the below a) create an …

Total answers: 1

reading Excel file Date/time Incorrectly

reading Excel file Date/time Incorrectly Question: I have an excel file with a column as time and a separate column as date. I’m using the code below to read it : df = pd.read_excel(r’df.xlsx’, parse_dates=[[‘date’, ‘time’]]) This works perfectly when the date is the same; however, if the dates change then it read it falsely. …

Total answers: 1

How to compare two columns in Excel using Python?

How to compare two columns in Excel using Python? Question: I have to excel files with the following fields file1 col1,col2,col3,col4,col5,col6,col7,col8,col9 server1,java_yes,…. server2,java_no,…. server4,java_no,…. server8,java_no,…. file2 col1,col2,col3,col4,col5,col6,col7,col8,col9 server1,java_yes,…. server3,java_no,…. server4,java_yes,…. server8,java_no,…. I want to a. Iterate over file1 b. Compare each entry in col1 in file1 against col1 in file2 c. If it exists, I …

Total answers: 2