0

I'm looking for a solution to drop column index in my code. Any help would be greatly appreciated. Thank you.

from tkinter import *
from tkinter.ttk import *
import tkinter as tk
import pandas as pd
from tkinter import ttk

#create window
window = tk.Tk()
window.title("Basic H/W status reporting")
window.geometry("750x600")
window.configure(bg='white')

df = pd.read_excel ('C:/Users/sgtiocqn/Desktop/females.xlsm', sheet_name= 'females')
df1 = pd.DataFrame(df, columns=["region"])

df1.drop(labels=None, columns="region", level=None, inplace=False, errors='raise')
print(df1)

window.mainloop()

This is how the result looks like now (using the code above) -

before

What I'm trying to get -

after

ATTEMPTS I have tried using .to_numpy() and this is the messy result...

numpyresult

Also, when I'm trying to continue from numpy code, I can't drop duplicates/sort values using df.drop/df.drop_duplicates/df.sort_values.

Error received(e.g.):

AttributeError: 'numpy.ndarray' object has no attribute 'drop_duplicates'

Akash senta
  • 483
  • 7
  • 16
  • Refer this [answer](https://stackoverflow.com/a/20107825/1079086) let me know if this is what you looking for ? – Akash senta Jun 25 '20 at 01:22

1 Answers1

0

Try this solution (this works for me):

print (df.to_string(index=False))

Akash senta
  • 483
  • 7
  • 16