Skip to content

Instantly share code, notes, and snippets.

@sherlockhomeless
Created December 2, 2020 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sherlockhomeless/80be5aff99d6d3933574ea012d8cec05 to your computer and use it in GitHub Desktop.
Save sherlockhomeless/80be5aff99d6d3933574ea012d8cec05 to your computer and use it in GitHub Desktop.
Delete Columns/Rows from Excel Sheet in Python
#!/usr/bin/env python3
import pandas as pd
excel_file_path = 'modify.xlsx'
def read_excel(path: str):
return pd.read_excel(path)
e = read_excel(excel_file_path)
print(f'##### BEFORE #####\n\n {e} \n\n\n')
# delete column
del (e[0])
# delete row
e = e.drop(index=0)
print(f'##### AFTER #####\n\n {e}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment