I hope you can help me to sovle my problem, I am trying to do a programm where I can print out a pdf with a table that have 3 variable po#,name and description, when I used panda and I introduce PO# and convert this to html and then pdf, this happensIt shows everything but it has a row that contain a 0 with it and I can not dele this with drop(), how can I do to delete this?
It shows everything but it has a row that contain a 0 with it and I can not dele this with drop(), how can I do to delete this?
this is my code THIS IS THE CODE
CodePudding user response:
Without the CSV file, it's tricky to estimate from where the zero may come from. However, from the pandas official documentation, the loc
accepts the labels of the rows and only accept:
- single labels (and accesses the whole raw);
- a range of rows;
- boolean array or Series (all
True
indexes will be selected); - a callable function that returns one of these;
- a list of labels.
That means the loc[]
method doesn't accept the grid position of the cell listed with commas but instead a label to the column. In your case, when you type file.loc[0, "P)#"]
, Pandas treat 0
as a label of a row. Remember that loc[]
treats all values as labels and never as indexes, therefore what I suggest you to do instead is to select the "PO#" row and assign its first item to the desired value:
file.loc["PO#"][0] = po_number
CodePudding user response:
I think you are talking about the head of the columns. You can rename the column headings. If you want to hide the column the use hide.
To rename column there are different methods one option is a list.
df.columns = [["column name"]]
To hide the column head I recommend that you read the documentation but it would be something like...
df.style.hide(axis="columns")
Place the DataFrame on the clipboard with out the header, try this...
df.to_clipboard(header=False)