Hey Everyone! Continuing the Pandas series. In this one we’ll work with multiple spreadsheets and use the GroupBy pandas function.
We’ll cover:
– Combining data sources
– Grouping data from multiple sources
#Python #Pandas #FiveMinutePythonScripts
Thanks so much for all the support! You all are incredible. Everything I type this message in my video descriptions it makes me smile. 3930+ Subscribers! How awesome – Thank you all š
*****************************************************************
The Excel Sheets I used (Just dummy data):
Workbook1.xlsx –
https://drive.google.com/open?id=1a11pvERd-Z9oy5nGXDJK-bDwOMiDhRTc
A second (optional workbook with same data structure) –
https://drive.google.com/file/d/1os_vUINGjx8_NPv7S0BzeYuMp7GMDU37/view?usp=sharing
Full code from the video:
import pandas as pd
excel_file = ‘Workbook1.xlsx’
df_1 = pd.read_excel(excel_file)
df_2 = pd.read_excel(excel_file, sheet_name=’2nd’)
print(df_1.head(5))
print(df_2.head(5))
frames = [df_1, df_2]
all_data_df = pd.concat(frames, axis=0)
print(all_data_df)
productivity_df = all_data_df.groupby([‘Operator’,’Line #’]).mean() #.min() .max() . sum()
print(productivity_df[‘Amount’])
*****************************************************************
Code from this tutorial and all my others can be found on my GitHub:
https://github.com/Derrick-Sherrill/DerrickSherrill.com
Check out my website:
https://www.derricksherrill.com/
If you liked the video – please hit the like button. It means more than you know. Thanks for watching and thank you for all your support!!
Always looking for suggestions on what video to make next — leave me a comment with your project! Happy Coding!
source
Thank you! Very useful š
GREAT.
im a beginner and im gonna try your tutoriais
Great stuff my question is what if you want to create the pivot with some of you values as sum and some as mean
Thanks
okay now how do we plot it lol
WOW Thank you Derrick !! It s exactely what i m looking for long time. How can i
drill to the pivot table data to have the details of the table like in
Excel ??
Hi DerrksherrilL, I have multiple excel files with data in them, the file name contains the temperature data (P30deg.xlsx, P31deg.xlsx, P32deg.xlsx, also M20degC.xlsx, M21degC.xlsx etc.) How to read all the excel files in one go and filter out based on the temperature.
Is there some way to automate the pasting of data from python to Excel
How to write back the pivot results to excel again
great video
Easy to understand. Cool. Keep it up š
Hi Derrick, question, if i want to concatenate 3 column that is operator, Line no and Product and return the Amount Column so how can I do it ?
DO YOU HAVE ANY BOOK RECOMMENDED FOR BEGINNERS
Hi Derrick, great videos, thanks for sharing! Maybe you could help me with one issue I encounter following your script: executing the python code in atom, via the internal terminal, I receive an error, that "no module named pandas could be found". Any tips?
Thx Martin
Excellent! I'm learning a lot with your tutorials about Pandas. I am beginning my learning about data science. Thank you for sharing your knowledge with us.
Brilliant stuff. Short and concise. Keep uploading!
loved it, good teacher!
Awesome video!! I thought for a moment that you were doing something like using concat() for multiple dataframes and then and pivot_table(). I really enjoy your videos, and never miss one.
Derrick, your video tutorials are so awesome. They're short, concise and to the point. Please keep up. I have found your videos the easiest to follow with regards to learning little things here and there about Python and actually applying them to my work.
Amazing let me try this and get back
The clear explanation for every coding lines makes the video so engaging especially for Python beginners. šššš
Hi Sir,
Can you please make video on Python to filter excel sheet based on other excel sheet value and copy filtered data into another excel file….
Thank you!