to_excel attribute doesn't work

Multi tool use
Multi tool use


to_excel attribute doesn't work



I opened an excel file as a df. I made some manipulations, added a column and now I'm trying to export the df to a different excel



Here's my code:


import pandas as pd
import numpy as np
import math

global df
pd.set_option('expand_frame_repr', False)

df = pd.read_excel('C:Userstal.elisbergDesktopאלטשולרsmartass.xlsx', None)

Ezer = df['Data']

vals = Ezer['abs hundred']
vals = list(vals)
teur_list = list(Ezer['Teur'])
rows = [None]*(len(teur_list))

vals = [str(round(x,2)) for x in vals if math.isnan(x) == False]

for i in range(len(vals)):
for j in range(len(teur_list)):
if vals[i] in teur_list[j]:
rows[j] = int(i)


df['Data']['Rows'] = pd.Series(rows, index=df['Data'].index)

writer = pd.ExcelWriter('PythonExport.xlsx')
df.to_excel(writer,'Sheet1')
writer.save()



the error : 'collections.OrderedDict' object has no attribute 'to_excel



Any suggestions as to why it is throwing an error?





The error is clear. You don't have a dataframe object, you have a ordereddict (which has no to_excel method). By the way, the code you showed us has no line with to_excel being called. Are you sure you posted the right part of the code?
– RafaelC
Jul 2 at 12:51



dataframe


to_excel


to_excel





df = pd.read_excel('C:smartass.xlsx', 0) should be ok to "translate" to dataframe the first sheet.
– Vityata
Jul 2 at 12:53


df = pd.read_excel('C:smartass.xlsx', 0)





i pasted the wrong code, just updated it, if you can re-relate to my question
– Talis
Jul 3 at 7:24










By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

MCsnV451EqCzyfvl16iBmS9,6LhEoUeqmXKLFs1A9VclMLP00Hxy,i3J42p,8
kyOiI8,TyMqMt Iw46SSu ZloJVxNhr1NpF9WfCAmB5 K 0 nyox5,LhMgRvZyQk

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications