I am getting an error that seems... wrong. Because of course worksheet object has set_column() as a function, it's in the docs. I've probably done something dumb like drop a parenthesis.
Here's the error:
Traceback (most recent call last):
File "scrubaddresses.py", line 137, in <module>
run()
File "scrubaddresses.py", line 118, in run
format_col_width(worksheet)
File "scrubaddresses.py", line 24, in auto_format_cell_width
ws.set_column('B:C', 20)
AttributeError: 'Worksheet' object has no attribute 'set_column'
Here's my ridiculous import. Config is some constants, controller has some helper functions.
from smartystreets_python_sdk import StaticCredentials, exceptions, Batch, ClientBuilder
from smartystreets_python_sdk.us_street import Lookup as StreetLookup
from pathlib import Path
import pandas as pd
import numpy as np
import config
from controller import getExcel, clean
The func in question:
def format_col_width(ws):
ws.set_column('B:C', 20)
ws.set_column('D', 1)
ws.set_column('E', 20)
Where the ws being passed comes from:
df1 = df.replace(np.nan, '', regex=True)
print(df1)
df1.to_excel(writer, sheet, index = False, engine='xlsxwriter')
worksheet = writer.sheets[sheet]
format_col_width(worksheet)
Did I forget to import something? Xlsxwriter is installed.