Home > other >  Python is an Excel table split into multiple Excel tabulated fault, strives for the great god
Python is an Excel table split into multiple Excel tabulated fault, strives for the great god

Time:09-21

 import pandas as pd 
Data=https://bbs.csdn.net/topics/pd.read_excel (r "C: \ Users \ \ Administrator \ institute of computer technology and software engineering. XLS")
Rows=data. Shape [0] # access lines shape [1] for the number of columns
Department_list=[]

For I in range (rows) :
Temp=data [" class "] [I]
If temp not in department_list:
Department_list. Append (temp)

For department in department_list:
New_df=pd. DataFrame ()

For I in range (0, rows) :
If the data [" class "] [I]==department:
New_df=pd. Concat ([new_df, data. The iloc [[I], :]], the axis=0, ignore_index=True)

New_df. To_excel (" C: \ \ Users \ \ Administrator \ \ Desktop \ \ warning 18 credits \ \ "" + STR +". XLS "(department), sheet_name=department, index=False)


Error: AttributeError Traceback (the most recent call last)
()
16 new_df=pd. Concat ([new_df, data. The iloc [[I], :]], the axis=0, ignore_index=True)
17
- & gt; 18 new_df. To_excel (" C: \ \ Users \ \ Administrator \ \ Desktop \ \ warning 18 credits \ \ "" + STR +". XLS "(department), sheet_name=department, index=False) # every sales department put into a new excel

D: \ anaconda \ lib \ site - packages, pandas, core, frame, py in to_excel (self, excel_writer, sheet_name, na_rep float_format, columns, header, index, index_label, while the startrow, startcol, engine, merge_cells, encoding, inf_rep, verbose, freeze_panes)
1764 the formatter. Write (excel_writer, sheet_name=sheet_name, while the startrow=while the startrow,
1765 startcol=startcol freeze_panes=freeze_panes,
-> 1766 engine=engine)
1767
1768 def to_stata (self, fname, convert_dates=None, write_index=True,

D: \ anaconda \ lib \ site - packages, pandas, IO, formats \ excel py in the write (self, writer, sheet_name, while the startrow, startcol, freeze_panes, engine)
650 writer. Write_cells (formatted_cells, sheet_name,
While the startrow=651, while the startrow startcol=startcol,
--> 652 freeze_panes=freeze_panes)
653 if need_save:
654 writer. The save ()

D: \ anaconda \ lib \ site - packages, pandas, IO \ excel. Py in write_cells (self, cells, sheet_name, while the startrow, startcol, freeze_panes)
1471 WKS=self. Sheets [sheet_name]
1472 else:
-> 1473 WKS=self. Book. Add_sheet (sheet_name)
1474 self. Sheets [sheet_name]=WKS
1475

D: \ anaconda \ lib \ site - packages \ XLWT \ Workbook py in add_sheet (self, sheetname, cell_overwrite_ok)
364 from the Worksheet import Worksheet
365 if not isinstance (sheetname unicode_type) :
--> 366 sheetname=sheetname. Decode (self. Encoding)
367 if not Utils. Valid_sheet_name (sheetname) :
368 the -raise Exception (" invalid worksheet name % r "% sheetname)

AttributeError: 'int' object has no attribute "decode"
  • Related