0

Newbie here. I have 3 columns in my data. I am exporting the data to an excel and the file name needs to include all the 3 column names in it. Using dataframe and dataset here.
Ex- ProjectNo-Area-Division.
The problem is Area is 3 digits. Some areas are '000', '010', '020', '01A'
If i use the below line

file_name = final_dataframe['PROJECT NUMBER'].unique()[0] + '-' + str(final_dataframe['AREA'].unique()[0]) + '-' + str(dataset['DIVISION'].unique()[0]) + '.xlsx'

file_name = ProjectNo-0-DIVISION ProjectNo-10-DIVISION
ProjectNo-20-DIVISION
ProjectNo-01A-DIVISION respectively.
How can I get all 3 digits in the file name, irrespective of being 0. TIA

1
  • thanks. i tried the same and it worked Commented Jun 19, 2020 at 15:53

1 Answer 1

1

When you convert your areas to strings, the integer ones are losing their leading zeros. You can add them back using zfill:

file_name = final_dataframe['PROJECT NUMBER'].unique()[0] + '-' + str(final_dataframe['AREA'].unique()[0]).zfill(3) + '-' + str(dataset['DIVISION'].unique()[0]) + '.xlsx'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.