-1

I have this excel file and I would like to delete all blank cells in columns A and shift the populated cells up using python.

Not sure how to do this, any advice? I know I can go into excel and do it manually but I need to automate this process. Multiple files looking just like this will be created, and I need to automate adjusting this so that all those populated cells in column A actually sit next to the rest of the data in B, C, D, E.

enter image description here

brice0408
  • 61
  • 4
  • [Duplicated Question] Use pandas. For further reference: https://stackoverflow.com/questions/43119503/how-to-remove-blanks-nas-from-dataframe-and-shift-the-values-up – Mattheus Sant'Anna Apr 05 '22 at 23:45
  • Does this answer your question? [How to remove blanks/NA's from dataframe and shift the values up](https://stackoverflow.com/questions/43119503/how-to-remove-blanks-nas-from-dataframe-and-shift-the-values-up) – George Apr 25 '22 at 18:06

1 Answers1

1

Use pandas to import and modify your excel.

import pandas as pd
df = pd.read_excel('yourfile.xlsx')
df = df.apply(lambda x: pd.Series(x.dropna().values)).fillna(' ')