I want to use Python to create an Excel pivot table. Can't find any working code to accomplish this, anyone know a library I could use?

like
Posting as :
works at
You are currently posting as works at

import pandas as pd

# Sample data
data = {
'Date': ['2023-01-01', '2023-01-02', '2023-01-03', '2023-01-01', '2023-01-02'],
'Region': ['East', 'West', 'East', 'North', 'South'],
'Sales': [100, 150, 200, 130, 170]
}

df = pd.DataFrame(data)

# Create a pivot table
pivot_table = df.pivot_table(index='Date', columns='Region', values='Sales', aggfunc='sum')

# Write to an Excel file
excel_file = 'pivot_table.xlsx'
with pd.ExcelWriter(excel_file, engine='xlsxwriter') as writer:
pivot_table.to_excel(writer, sheet_name='PivotTable')

# Get the xlsxwriter workbook and worksheet objects.
workbook = writer.book
worksheet = writer.sheets['PivotTable']

# Add some formatting
format1 = workbook.add_format({'num_format': '#,##0.00'})

# Set the column width and format
worksheet.set_column('A:A', 15, format1)
worksheet.set_column('B:D', 10, format1)

like

Give chatgpt a try for things like that! Had a lot of success there with excel help. Even just asking basic things, what is the best way to do [insert thing]. Whether or not it is the best way, not always sure, but it is always a way to do it! Definitely give it a try next time you are stuck on something.

I second the chat gpt recommendation. I will sometimes describe my df and what I want to accomplish and then work back and forth with it until I have what I want. Works surprisingly well tbh

f

Literally use .pivot_table() in pandas, lol I’m sure you can find some examples if you google it

I think ChatGPT can help you

Related Posts

I’m a Junior accountant, recent MBA grad in Finance, located in NYC, just got laid off due to a merger. Anybody hiring or know any opening positions?

like

Hi fishes, any openings for SAP consultant in American Express in India

like

Offered a salary of 92K for a Business Analyst position at Facebook NYC in the Marketing Intelligence team. What’s the typical range? I have more than 2 years of work experience

like

By when does EY releases offer letter?
It has been 2 weeks since salary discussion with HR. Now HR is not picking call or responding to follow up mails.
Should I keep hope as the wait is really frustrating!!EY

like

Looking for a good recruiter in central to puppet Florida...anyone have any one that they can recommend?

Anyone here works at Samsung R&D Noida in Ad operations?

like

What’s the difference between contracting vs consulting? I’d like to know peoples thoughts. 1 in the same?

Anyone from Leidos? Anyone? ...... *crickets*

like

Thinking of an affordable brown leather automatic watch. Thoughts on shinola runwell automatic? Any alternatives you would recommend?

like

What’s the oldest watch you have? Excl digital and quartz watches as those things last forever.

like

Didn’t think I’d pick up a new watch, but love this new Tudor Black Bay 58 925. Technically my first “precious” metal watch.

Post Photo
like

Have any of you found it worthwhile to think about why you are an addict? Care to share?

like

Hi ,

I am very much interested to know if IBM India has any node js projects?
Has any one have any experience of working on node.js /express.js or MERN stack developer at IBM?
TIA

What are the working hours at Cyntexa? Is there any flexibility?

like

What is the package range for lowest position in Band 6 like 6C or Analyst 1 designation ??

like

How long are public trust background checks taking. I'm at two weeks of waiting!

like

Has anyone in your company heard the word (cross-connect) or (leased Line) perhaps you have heard this from the network team at your financial institution?

like

Could someone please suggest how to handle this situation?
My manager (Technology Director) sees me as an emerging thread to his position and stopped sharing details / trying to avoid including me in visible projects etc.,
FYI - His manager is the division head and Managing Director.
Why I think my manager tries to move me out?
- I am 18 YOE with a technically strong background
- Upper mgmt is starting to identify me as the backup for all systems. My manager tries to move me out since then

likehelpful

Just did sit ups. Walked into the bathroom to check, still nothing 😐

likefunny

Additional Posts in Data Analytics & Data Science

Does anyone here have experience building product analytics? I am the first product analyst in my team and I work with approximately 6 PMs. Any help is appreciated

like

Hi all,
I graduated during Covid with a double major in business administration and business management with a minor in marketing and magically ended up in sales because I needed a job. I’m about to take a data analytics course to make an attempt to break into that field. I’m currently looking for a mentor to help guide me during this time. Also, if anyone is willing to look over my resume and give me tips on how to make it more presentable for recruiters in DA that would be very helpful. Thanks

like

Hi All, I am currently a Data Analyst with 1 year of experience and pursuing a masters in Computer Science (expected to graduate 5/2023). I am looking to transition into an entry Data Scientist role (preferably remote or Philadelphia, PA). Can someone refer me or let me know who is hiring?

I can provide my resume if needed.

Does anybody here do any side work for extra income using their data expertise? I would love ideas that I could do from ~5-15 hours a week. Tutoring is the only thing that comes to mind immediately. Thanks in advance!

helpful

Would like some opinions about how likely it is to make product analytics self serve by PMs? Anybody have success here? Or is it hopeless to think that product managers can pull their own data, look at their own dashboards, and do basic data tasks themselves?

like

How do you know your value? Throughout my 10 yrs of being in a professional setting, I've had colleagues from various places of employment say, I don't think you know your worth. You're under valued, etc. What exercises/tools have helped you realize your worth and effectively advocate for it? TIA!

like

Hi , I recently started preparing for " data analyst" course. I have masters degree in computer science and 2 years experience as business analyst. Currently I'm on a career break of almost 7 years and trying to get back into IT as a data analyst now.
I started doing a course on coursera " Google data analytics certificate " . I'm not sure how to get back into job market. Please suggest any courses or road map to entry level data analyst jobs?

like

Senior to Manager-level Data Scientists, what is the minimum set of skills and experience you require someone to have in order to train them to be a Data Scientist?

I have a handful of people from BI and Marketing who want to learn how to be a "Data Scientist" where some of them have stronger SQL knowledge and ability than others, but some of them have more exposure to languages like Python and R, and a little bit of machine learning exposure.

Appreciate the input in advance.

What is the market like for entry level data scientists/ data analyst. I have a graduate certificate in data science and have spent the last 27 years as a mainframe dev so I have great SQL skills.

like

Could someone help me break down the differences between a Data Analyst vs Data Scientist vs Product Manager? And add any pros/cons from personal experience? In my mind they’re all related, but I don’t have experience working with any of these roles.

Hi -

So I got hired to build out the data function of my company. But I’ve noticed that there are certain leadership members that don’t seem to respect my function nor think data is that important. Has anybody faced this problem? Any advice?

funny

How is it to work as a Data Scientist at Morgan Stanley ? How os the data culture ?

like

Good morning, hope everyone is having a great week! Does anyone have any advice on breaking into an analyst role? I am currently a Senior Customer Success Manager, with a background in Operations/Process and Project Management as well. I have always enjoyed the analysis pieces of my roles and would love to expand my skills to show how qualified for a position in data analytics. Thank you in advance for the help!

like

I’ve got about 20 years cross channel experience in marketing, split between big brands and startups, and I’m considering pivoting into a data science/data analyst role. I know it will initially be a step back in comp but is it at all realistic for a person with certificate level experience in data analysis but a decent marketing management background to expect $150-200k comp or is that mostly for degreed candidates (or not realistic at all)? Any guidance here is greatly appreciated.

like

There is a MS program in Data Science at CUNY SPS. I am considering to take that program or do the CFA. Does anyone have any insight about the program?

Here is my go-to interview question, "What is the difference between data science and data analytics?"

What questions does everyone else include when interviewing or is the best question you've been asked in an interview?

like

Can anyone please share what salaries for Data Analysts are like in Bangalore, India for someone with about 2-4 years experience? Roughly how much per year can Data Analysts for large organizations expect to make?

like

I have 5 YOE in Analytics... always thought I wanted to be a DS, but every job (even the junior ones) required experience in ML development. Though I am part of the ML project, I'm not the person develop the model. And I have a hard time when the interviewer ask about how I develop the model and what hyperparameters I tuned. I know the thought process and stuff but 'I' wasn't the one who did that part in the project. How to convince them that I could do the job without taking credit of others.

like

I like to pursue in the data science field. I have business Analyst experience but to switch to data science field could you guide me on what should I learn? Where should I start?

like

New to Fishbowl?

Download the Fishbowl app to
unlock all discussions on Fishbowl.
That was just a preview…
Sign Up to see all discussions
  • Discover what it’s like to work at companies from real professionals
  • Get candid advice from people in your field in a safe space
  • Chat and network with other professionals in your field
Sign up in seconds to unlock all discussions on Fishbowl.

Already a user?
Login here

Share

Embed this post

Copy and paste embed code on your site

Preview

Download the
Fishbowl app

See what’s happening in your industry
from the palm of your hand.

A phone with Fishbowl app

Scan your QR code to download
Fishbowl app on your mobile

Download app

Sign up for free to view this conversation on Fishbowl

By continuing you agree to Terms of Use and Privacy Policy

Already have an account? Log in

Sign up for free to continue using Fishbowl

By continuing you agree to Terms of Use(New) and Privacy Policy(New)
Messaging rates may apply

Already have an account? Log in

For account settings, visit Fishbowl on Desktop Browser or

General

Legal