Python Forum
Python code for alignment and font size
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python code for alignment and font size
#1
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.
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)
Below is the code I use in VBA and would like the same in Python.
'VBA code select whole range to configure Range("A1").CurrentRegion. HorizontalAlignment = xlLeft Range("A1").CurrentRegion. VerticalAlignment = xlTop Range("A1").CurrentRegion. Font.Size = 10
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How can I write formatted (i.e. bold, italic, change font size, etc.) text to a file? JohnJSal 13 35,366 May-20-2025, 12:26 PM
Last Post: hanmen9527
  Python 3.13 : def setup size HansieB 6 2,367 Dec-02-2024, 11:12 AM
Last Post: buran
  How to do "fixed size" (wrapping) math in Python? AlexanderWulf 13 8,295 Jul-19-2023, 04:13 PM
Last Post: deanhystad
  make all text in Right to left alignment in tkinter widgets jalal0034 1 3,810 Sep-27-2022, 06:42 PM
Last Post: Larz60+
  Right to left alignment in python report using Reportlab jalal0034 1 6,963 Sep-27-2022, 04:25 AM
Last Post: jalal0034
Question Opening small size browser with python selenium not work, need help greenpine 0 2,753 Feb-07-2022, 11:36 AM
Last Post: greenpine
  pandas, tabulate, and alignment menator01 3 14,500 Feb-05-2022, 07:04 AM
Last Post: menator01
  How to set Tab size to 4 in Python interpreter? zzzhhh 1 3,284 Jan-18-2022, 12:11 PM
Last Post: snippsat
  Space between list and column alignment rturus 8 9,347 Mar-17-2021, 04:47 PM
Last Post: rturus
  Load external font and does not show font in the window ATARI_LIVE 16 15,057 Feb-05-2021, 10:36 PM
Last Post: EthanPayne

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.