5 examples of 'exporting dataframe to excel python' in Python

Every line of 'exporting dataframe to excel python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
634def export_matrix_to_excel(row_names, col_names, matrix, filepath='export.xlsx', sheetname='Export'):
635 workbook = xlsxwriter.Workbook(filepath)
636 ws = workbook.add_worksheet(sheetname)
637 # formatting
638 # border
639 format_border = workbook.add_format()
640 format_border.set_border(1)
641 format_border.set_font_size(9)
642 # border + text wrap
643 format_border_text_wrap = workbook.add_format()
644 format_border_text_wrap.set_text_wrap()
645 format_border_text_wrap.set_border(1)
646 format_border_text_wrap.set_font_size(9)
647 # set column width
648 ws.set_column(0, 1, width=15, cell_format=None)
649 ws.set_column(1, 50, width=9, cell_format=None)
650 # write data
651 for i, p in enumerate(col_names): # process names
652 ws.write(0, i+1, p, format_border_text_wrap)
653 for i, p in enumerate(row_names): # product names
654 ws.write(i+1, 0, p, format_border)
655 for i, row in enumerate(range(matrix.shape[0])): # matrix
656 ws.write_row(i+1, 1, matrix[i, :], format_border)
657 workbook.close()
49def write(self, row_n, col_n, value):
50 '''写入数据,如(2,3,"hello"),第二行第三列写入数据"hello"'''
51 self.ws.cell(row_n, col_n).value = value
52 self.wb.save(self.filename)
15def export_set(dataset):
16 """Returns a TSV representation of Dataset."""
17
18 stream = StringIO()
19
20 if is_py3:
21 _tsv = csv.writer(stream, delimiter='\t')
22 else:
23 _tsv = csv.writer(stream, encoding=DEFAULT_ENCODING, delimiter='\t')
24
25 for row in dataset._package(dicts=False):
26 _tsv.writerow(row)
27
28 return stream.getvalue()
84def WriteToExcel():
85 f = open('wordbank.csv','w')
86 list = CountInstancesGlobal()
87 for twoplet in list:
88 f.write(str(twoplet[0]))
89 f.write(',')
90 f.write(str(twoplet[1]))
91 f.write('\n')
92 f.close()
325def exportInExcelFormat(self):
326 if not self.__fh.closed:
327 self.close()
328 self.excelfileName = Utilities.createExcelFileFromFileAndReturnName(
329 self._fileName)

Related snippets