last day (14 days later) » 

3:47 PM
0
A: Trouble creating pandas pivot table with preexisting Excel file

Alexparse is a method (function attached to an object). So you need parentheses after the method name i.e. df = excel.parse(). See the docs for details on how to supply arguments to the function call.

 
Thanks for pointing that mistake out. What would I pass the parse function in order to make this work? I tried giving it sheetname = 0 but then it gave me this error: KeyError: "['Supervisor'] not in index"
 
Please post your DataFrame or a sample of it (click edit in the original question to add it).
 
Would I do that by just writing print df1 ?
 
That will do it. Then copy and paste the results.
 
For some reason when I tried to print the DataFrame it was telling me that Supervisor was not in the index. Then I removed it from the declaration of df1 and then printed it and it printed out this paste.ubuntu.com/20320550
 
3:47 PM
Try printing df instead of df1.
Also, please open a new question. That way if someone is reading this, they will know the answer to the question originally posed.
 
Problem solved with the supervisor not being in the index. I had to save the workbook prior to starting to make the pivot table.
Because I created the supervisor column a bit earlier up in the code.
 
Sounds good.
 
I'm still getting an error with my declaration of the pivot table however.
TypeError: pivot_table() got an unexpected keyword argument 'index'
 
That's weird
Can you mark this question as closed and post a new question.
With the code you now have and a print out of your DataFrame.
 
Yes I will just a sec
 
3:50 PM
'index' is a keyword argument to that function - pandas.pydata.org/pandas-docs/stable/generated/…
 
Am I able to close my own question
or do i need more points?
Should I just delete the question?
 
In general if your question is answered. Mark it as answered (the check mark next to an answer).
You can also vote for more than one answer if you think multiple answers have value by clicking the up arrow next to an answer.
(You can only mark one answer as correct with the check mark)
This let's people know that the problem has been solved.
 
Ah wait.
I found online that I should replace index with 'rows' and columns with 'cols'
and that worked, but now I get an error saying ImportError: No module named style
from this line ImportError: No module named style
 
I really can't do anything unless you post the DataFrame.
 
Product Description Supervisor
0 EXPRESS 12:00 (doc) Gordon
1 EXPRESS 10:30 (nondoc) Vinny P
2 EXPRESS 12:00 (doc) Vinny A
3 EXPRESS 12:00 (nondoc) Building
4 EXPRESS 12:00 (nondoc) Building
5 EXPRESS 12:00 (nondoc) Building
6 EXPRESS 12:00 (nondoc) Gordon
7 MEDICAL EXPRESS (nondoc) Gordon
8 EXPRESS 10:30 (nondoc) Vinny A
9 EXPRESS 12:00 (doc) Pete
10 EXPRESS 12:00 (nondoc) Vinny P
11 EXPRESS 10:30 (nondoc) Building
 
3:56 PM
And like I said, posting a question along the lines of "Here's what I want... Here's what I've tried... Here's the error message I'm getting..." is the best way to ask a question.
When you post here, the spacing gets screwed up so I can't copy and paste it.
Please ask a new question.
 
Okay.
 
If you send me a link to a new question, I will look at it.
 
I can only post once every 90 minutes, but here's what the post will be
 
Looks good. I would add what line the error is coming from.
(what line in your code)
Adding the full traceback (error log) will probably help for this problem.
 
okay.
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1625, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/harrisonleggio/tdx.py", line 34, in upload
return process(f.filename)
File "/home/harrisonleggio/tdx.py", line 201, in process
table1.to_excel(writer, 'Pivot Table', engine = 'xlsxwriter')
File "/usr/lib/python2.7/dist-packages/pandas/core/frame.py", line 1204, in to_excel
startrow=startrow, startcol=startcol)
File "/usr/lib/python2.7/dist-packages/pandas/io/excel.py", line 530, in write_cells
I'm adding it to the post
but that's the traceback
The error is ImportError: No module named style
I had the wrong paste in that initial image I sent.
0
Q: Panda Pivot Table troubles -> No module named style?

hleggsI am getting this error: ImportError: No module named style, which is coming from this import statement: from openpyxl.style import Style Here is my code related to the pivot table: excel = pd.ExcelFile(filename) df = excel.parse(sheetname=0) df1 = df[['Product Description', 'Supervisor']] pri...

 
4:24 PM
Can you try reinstalling openpyxl?
 
Didn't fix it
It might have something to do with panda not being able to write styles?
or openpyxl not being able to write styles
I'm upgrading Pandas to see if that works.
Cause apparently there is an upgrade available for me.
 

last day (14 days later) »