Helper functions for .xlsx files
Project description
Xlsx filetype utility functions
Autofit_Columns: Autofit all columns from dataframe written to xlsxfile with xlsxwriter
def autofit_columns(dataframe, worksheet, padding=1.1, index=True):
"""
:param dataframe: Base dataframe written to xlsx workbook
:param worksheet: Sheet in xlsx workbook to be formatted
:param padding: Optional, padding amount
:param index: Optional, Index true/false in dataframe. Defaults true, use false for non-indexed dataframe outputs.
:return: formatted worksheet
"""
Example Call
import pandas as pd
import numpy as np
from mj.xlsxutility import autofit_columns
df = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
columns=['a', 'b', 'c'])
writer = pd.excelwriter("some_path",engine='xlsxwriter')
df.to_excel(writer)
autofit_columns(df,writer.sheets['Sheet1'],index=False)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xlsxutility-1.0.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for xlsxutility-1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b17c330be448fd20a1841a6b213e90d609067eed7fc8beaa6c097951eecd7bbd |
|
MD5 | 30544e2172e4056aa730a22f01d9094a |
|
BLAKE2b-256 | eac430bf170a47fcae8c8c3260e9db18b44be5af8727ae5405c2ba2cd91b4f85 |