python - Pandas DataFrame.to_excel How to ignore Formula -


first of looked on doc, on stackoverflow , google. did not find helps me decided post question, if miss had same problem, apologize.

this problem, have df named parameters :

     attribute            clause      value 0    distinguishedname          (.)*=_fr,dc=hld, dc=net 1    institution_label    ==         fakecompanyname inc. 2    employee_type        ==         1    3    email               not    (.)*.deleted 

and use pandas function to_excel write in xlsx file. creates file replaces == 0 in xlsx file because think detects string excel formula. know if possible ignore ?

to fix problem, add ' before == excel doesn't transform it. it's works. have '== in excel file instead of 0, want ==

does know better way ignore formula without having change value of dataframe's cell please ?

here's code :

writer = pd.excelwriter("exportations\\ddlcard_"+ddlname+".xlsx")  #replace == '== parameters["clause"] = parameters["clause"].apply(transformparametersclausetoignoreexcelformula)   list_dfs = {} list_dfs["parameters"] = parameters #we don't care df list_dfs["df2"] = df2 list_dfs["df3"] = df2 list_dfs["df4"] = df2   #foreach df, write on xlsx file on sheet named "key" key, df in list_dfs.items():     df.to_excel(writer,         sheet_name = key,         encoding = "utf-8",         index = false     )     writer.sheets[key].set_column('a:co', 25) writer.save()   def transformparametersclausetoignoreexcelformula(value):     return re.sub(r"==","'==",value) 

thank !

ps : forgive me if made mistakes, english not mother tongue language


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -