def sheets_2_excel(filename, sheets, index=False): # Sheets is iterable of tuples (sheet_name, columns, rows) pandas = import_pandas() writer = pandas.ExcelWriter(filename) for sheet_name, columns, rows in sheets: df = pandas.DataFrame(rows, columns=columns) df.to_excel(writer, sheet_name=sheet_name, index=index) writer.save()
def from_excel(filename, triangular='L'): df = import_pandas().read_excel(filename, sheetname='Sheet1') columns = list(df.columns[1:]) if triangular.upper() == 'L': list_values = [list(df[c1][i+1:]) for i, c1 in enumerate(columns[:-1])] else: raise NotImplementedError('Upper triangular') return CorrelationMatrix(columns, list_values=list_values)
def table_data_2_pandas(column_data_types, rows): columns, data_types = zip(*column_data_types) rows = cast_table_data(data_types, rows) return import_pandas().DataFrame(rows, columns=columns)
def rows_2_excel(filename, columns, rows, index=False): import_pandas().DataFrame(rows, columns=columns).to_excel(filename, index=index)
def to_excel(self, filename, header=True): from common_utils.import_method import import_pandas df = import_pandas().DataFrame(self.get_rows(), columns=self.get_column_names()) df.to_excel(filename, index=False, header=header)