Jan-14-2024, 03:56 AM
Hi, I would like help with a code to align left and top and change font size to 10 similar to VBA code. The code I am creating is below, cheers.
Below is the code I use in VBA and would like the same in Python.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import pandas as pd inspdata = pd.read_excel( 'Inspections data.xlsx' ) #remove columns inspdata.drop([ 'Notice Creation' , 'count()' ],axis = 1 , inplace = True ) #replace header row names inspdata.columns = [ 'EForm ID' , 'Contractor' , 'Address' , 'Area' , 'Classification' , 'Program' , 'Notice Ref #' , 'Category' , 'Inspection Type' , 'Result' , 'Actual Date' , 'Created Date' , 'Status' , 'CIO' , 'PO' ] #delete first 4 rows below the header inspdata.drop([ 0 , 1 , 2 , 3 ],axis = 0 ,inplace = True ) #keeps header row #replace text inspdata[ 'Classification' ].replace([ 'VACQREP' , 'VACAP' ],[ 'VAC' , 'VAC' ],inplace = True ) print (inspdata.head( 10 )) inspdata.to_excel( 'Inspections Data Python.xlsx' ,index = False ) |
1 2 3 4 |
'VBA code select whole range to configure Range ( "A1" ).CurrentRegion. HorizontalAlignment = xlLeft Range ( "A1" ).CurrentRegion. VerticalAlignment = xlTop Range ( "A1" ).CurrentRegion. Font.Size = 10 |