4 new time-saving tricks in pandas




[ad_1]

In the last 20 months, the pandas library has been updated 10 times, introducing hundreds of new features, bug fixes, and API changes. In this video, I’ll show you 4 new pandas tricks that will make your life easier!

1:18 Create a datetime column from a DataFrame
4:24 Create a category column during file reading
7:45 Convert the data type of multiple columns at once
9:48 Apply multiple aggregations on a Series or DataFrame
13:14 Bonus: Download the official pandas cheat sheet

== RELATED VIDEOS ==
My entire pandas video series: https://www.youtube.com/playlist?list=PL5-da3qGB5ICCsgW1MxlZ0Hq8LL5U3u9y
Working with dates and times: https://www.youtube.com/watch?v=yCgJGsg0Xa4&list=PL5-da3qGB5ICCsgW1MxlZ0Hq8LL5U3u9y&index=25
Using the category data type: https://www.youtube.com/watch?v=wDYDYGyN_cw&list=PL5-da3qGB5ICCsgW1MxlZ0Hq8LL5U3u9y&index=21
Changing data types: https://www.youtube.com/watch?v=V0AWyzVMf54&list=PL5-da3qGB5ICCsgW1MxlZ0Hq8LL5U3u9y&index=13
Using groupby: https://www.youtube.com/watch?v=qy0fDqoMJx8&list=PL5-da3qGB5ICCsgW1MxlZ0Hq8LL5U3u9y&index=14

== OTHER RESOURCES ==
Jupyter notebook on GitHub: https://github.com/justmarkham/pandas-videos
pandas release notes: http://pandas.pydata.org/pandas-docs/stable/whatsnew.html
pandas cheat sheet: https://github.com/pandas-dev/pandas/blob/master/doc/cheatsheet/Pandas_Cheat_Sheet.pdf

== JOIN DATA SCHOOL ==
YouTube: https://www.youtube.com/dataschool?sub_confirmation=1
Newsletter: http://www.dataschool.io/subscribe/
Blog: http://www.dataschool.io/
Patreon: https://www.patreon.com/dataschool

Source


[ad_2]

Comment List

  • Data School
    January 19, 2021

    NEW FOR 2019: Learn my top 25 pandas tricks! https://www.youtube.com/watch?v=RlIiVeig3hc

  • Data School
    January 19, 2021

    Hi, please can you please make a video on how one can remove or drop a number of columns with similar names from a dataframe.
    If a video won't be possible, pwould you please send me through mail.
    Thanks, your videos have been of great help.
    Email: olakunlebalogun247@gmail.com

  • Data School
    January 19, 2021

    Amazing!You are great

  • Data School
    January 19, 2021

    can you please make couple of vedios of real world data analysis problem using pandas?

  • Data School
    January 19, 2021

    At 9:30, tried using inplace=True instead of assignment. No warning, yet the drinks' columns' dtypes were still int64 instead of float64.
    drinks.astype({'beer_servings':'float','spirit_servings':'float'},inplace=True)
    ver. 0.24.2

  • Data School
    January 19, 2021

    Hi Kevin,

    Thanks for the wonderful vedio… I

    have question regarding your Tip 3. i have tried below code snippet; but unfortunately Column Continent is not converting to Category data type. why there is strange behavior. it is converting as expected in case of beer_servings to Float

    drinks.astype({'beer_servings':'float'},{'continent':'category'}).dtypes

    Output:

    country object

    beer_servings float64

    spirit_servings int64

    wine_servings int64

    total_litres_of_pure_alcohol float64

    continent object

    dtype: object

  • Data School
    January 19, 2021

    great lesson, thank you!

  • Data School
    January 19, 2021

    Thank you. I imagine you can do number 3 during the load as well: drinks = pd.read_csv('http://bit.ly/drinksbycountry', dtype={'beer_servings':'float', 'spirit_servings':'float'})

  • Data School
    January 19, 2021

    Is there a systematic way for pandas to determine which dataframe column may be helpful to convert into categories, or will that generally be contextual?

  • Data School
    January 19, 2021

    Thank you, Kevin. You are great! But honestly, I like your other style which you are writing codes during your videos. it is a lot more helpful.

  • Data School
    January 19, 2021

    fantastic! Thank you very much indeed for your time!

  • Data School
    January 19, 2021

    thank you Kevin! These are great videos that I learned a lot from. I have a question, why does pd.to_datetime(df[['month','day','year']]) has DOUBLE [[]] rather than SINGLE []??? I tried using ['month','day','year'], pandas gave me a error and I can't figure out what it meant.

  • Data School
    January 19, 2021

    how to convert data type of object to int? Do not know why my data shows numbers as object data type. Thank you!

  • Data School
    January 19, 2021

    Thank you Kevin, your videos are amazing. i got confident and interested to learn pandas and practice it.

  • Data School
    January 19, 2021

    Thanks Kevin ,
    Please create a video for Vlookup operations in Pandas

  • Data School
    January 19, 2021

    Thank you for your video,very happy to see you again.

  • Data School
    January 19, 2021

    Pls update more often

  • Data School
    January 19, 2021

    welcome back to here, Love to see your video!

  • Data School
    January 19, 2021

    How to create datetime columns during csv file reading? Thanks for the video!

  • Data School
    January 19, 2021

    Woooohooo you are back : D

  • Data School
    January 19, 2021

    Thanks for your content, amazing as always.

  • Data School
    January 19, 2021

    Thanks a lot , Kevin…

  • Data School
    January 19, 2021

    If you enjoyed this video, you should definitely check out my other new video, "5 new changes in pandas you need to know about": https://www.youtube.com/watch?v=te5JrSCW-LY&list=PL5-da3qGB5ICCsgW1MxlZ0Hq8LL5U3u9y&index=33

    Thanks for watching! 🙂

  • Data School
    January 19, 2021

    Another useful video Thanks

  • Data School
    January 19, 2021

    Thanks for your awesome videos. For me it is always the go to for the 'How was that again?'
    moments;)

  • Data School
    January 19, 2021

    Thanks a ton! Your videos have helped me a lot.

  • Data School
    January 19, 2021

    Welcome back! finally got some new videos to feed myself 😛

  • Data School
    January 19, 2021

    It's been a long time see you again Kevin. I am happy to see you again!

  • Data School
    January 19, 2021

    Hello Kevin. Love the video series. I am wondering, many videos are microscopic views of pandas. I am wondering if you can do a video series that is more macroscopic. For example: 1) How to read multiple csv files from one folder and iterate over them some function/program and then shooting it out. 2) Common problems to debug in pandas like when a csv has characters that pandas can't read. These big picture problems I find to be the most troublesome.

  • Data School
    January 19, 2021

    Your last trick is cool but talking about df.describe() I have used pandas-profiling package and it is awesome and gives you more insight. Good for EDA.
    Thanks for sharing these tricks

  • Data School
    January 19, 2021

    Thank you, Kevin.

    Best regards!

  • Data School
    January 19, 2021

    Welcome back 🙂

Write a comment