Replace Excel Vlookup with Python - Five Minute Python Scripts

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ก.ค. 2024
  • Subscriber special! We'll look at how we can replace the vlookup function in excel using python and pandas.
    Kite helps fund the channel, thanks for checking them out and supporting me --
    ⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. www.kite.com/get-kite/?...
    We'll cover:
    - Reading in multiple excel sheets
    - Merging dataframes
    - Renaming column names
    - Exporting to Excel
    #Python #Excel #Automation
    If you have your own request on what you want to see. Please let me know! I'm happy to help.
    THANK YOU ALL for so much support! You all are incredible. 3150+ Subscribers, I'm so glad you all enjoy the content enough to follow me. You all are awesome.
    *****************************************************************
    Full code from the video:
    import pandas as pd
    import numpy as np
    initial_workbook = 'A.xlsx'
    info_workbook = 'B.xlsx'
    output_workbook = 'output.xlsx'
    df_initial = pd.read_excel(initial_workbook)
    df_info = pd.read_excel(info_workbook)
    print(df_initial.columns)
    print(df_info.columns)
    df_initial.rename(columns={'Code':'IDs'}, inplace=True)
    df_3 = pd.merge(df_initial, df_info[['IDs','ID']], on='IDs', how='left')
    print(df_3)
    df_3.rename(columns={'IDs':'Code'}, inplace=True)
    df_3 = df_3.replace(np.nan, '', regex=True)
    print(df_3)
    df_3.to_excel(output_workbook, index=False)
    Or find it on my Github here:
    github.com/Derrick-Sherrill/D...
    *****************************************************************
    Code from this tutorial and all my others can be found on my GitHub:
    github.com/Derrick-Sherrill/D...
    Check out my website:
    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!!
    --- Channel FAQ --
    What text editor do you use?
    Atom - atom.io/
    What Equipment do you use to film videos?
    Blue Yeti Microphone - amzn.to/2PcNj5d
    Mic sound shield - amzn.to/3bVNkEt
    Soundfoam - amzn.to/37NV9ci
    Camera desk stand - amzn.to/3bX8xhm
    Box Lights - amzn.to/2PanL95
    Side Lights - amzn.to/37KSNut
    Green Screen - amzn.to/37SFFnc
    What computer do you use/desk setup?
    Film on imac (4k screen) - amzn.to/37SEu7g
    Work on Macbook Pro - amzn.to/2HJ5b3G
    Video Storage - amzn.to/2Pey8sw
    Mouse - amzn.to/2PhCtv3
    Desk - amzn.to/37O1Mv1
    Chair - amzn.to/2uqHE4E
    What editing software do you use?
    Adobe CC - www.adobe.com/creativecloud.html
    Premiere Pro for video editing
    Photoshop for images
    After Effects for animations
    Do I have any courses available?
    Yes & always working on more!
    www.udemy.com/user/derrick-sh...
    Where do I get my music?
    I get all my music from the copyright free TH-cam audio library
    th-cam.com/users/audiolibrary...
    Let me know if there's anything else you want answered!
    -------------------------
    Always looking for suggestions on what video to make next -- leave me a comment with your project! Happy Coding!
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 218

  • @GirayhanYlmaz
    @GirayhanYlmaz 3 ปีที่แล้ว +3

    I’ve been using excel for over 20 years now, more than half in professional life. I’ve been trying to automate stuff and decided on pursuing python for that reason. Thank you for sharing your experience and wisdom with us.

  • @codingwannabe
    @codingwannabe 3 ปีที่แล้ว

    Dude I don't usually comment on google videos however I feel inclined to tell you how useful your content is. I've watched some of your stuff and as someone new to Python that's transitioning from excel your help has been immeasurable. Thanks and keep it coming!

  • @gpozzi.
    @gpozzi. 4 ปีที่แล้ว +1

    Derrick, your channel is a real gem! Please keep up the good work! You just gained a new sub

  • @JenJHayden
    @JenJHayden 5 ปีที่แล้ว +36

    Multiple people accessing the same spreadsheet. Reduce human error. story of my life.

  • @Itshimaru
    @Itshimaru 4 ปีที่แล้ว +5

    Dude, you're just as awesome! The things you have shared are invaluable to people like me who are just beginning to learn Python. By far, your tutorial is best out there with all the actual real life applications. Thank you

  • @blaskowitzj
    @blaskowitzj 4 ปีที่แล้ว

    This is a huge help! Excel is so processing heavy that python makes things so much easier. Really appreciate your videos and please keep up the good work.

  • @Humito124
    @Humito124 5 ปีที่แล้ว +50

    Just started to learn python on my free time. As an accountant your channel is very helpful since you give examples of how I can use python to analyze data. Keep up the good work

    • @studywithrobin2715
      @studywithrobin2715 3 ปีที่แล้ว

      Former accountant turned web developer here! Derrick's awesome.

    • @ntenzz1808
      @ntenzz1808 2 ปีที่แล้ว +1

      @@studywithrobin2715 existing accountant who learn Python for data analytics here. Agree to the awesomeness

    • @mxrvxn08
      @mxrvxn08 2 ปีที่แล้ว

      if im working with large file, wilusing python be faster than the excel built in function or vba? thank u

  • @nkimomoleleki3716
    @nkimomoleleki3716 4 ปีที่แล้ว +1

    After watching this video I felt compelled to subscribe. A very good video, easy to follow and most importantly very helpful. Thanks man!

  • @jyaragon
    @jyaragon 4 ปีที่แล้ว

    Thanks. Very informative, quick and easy tutorial 👌. I’ve been spending lots of times trying to figure out how to do it in python until I came across your channel.

  • @gabrielreilly7010
    @gabrielreilly7010 3 ปีที่แล้ว

    I really like your videos. They answer practical questions the basic tutorials don't cover.

  • @redfeather22sa
    @redfeather22sa 3 ปีที่แล้ว

    I know this is super useful content !! Derrick I can't thank you enough !!!

  • @charitykahuria2892
    @charitykahuria2892 4 ปีที่แล้ว +6

    I found this at a time when I was almost giving up...Thank you

  • @Bubbles-qh7ez
    @Bubbles-qh7ez 3 ปีที่แล้ว +1

    your videos ae so good. This and your other excel videos ae just what I needed!

  • @tortilladmaiz
    @tortilladmaiz 4 ปีที่แล้ว +1

    you deserve more views i believe that this is the future im from tijuana and all the time is consumed by making reports documents on excel thank you sir

  • @saqibrauf2191
    @saqibrauf2191 5 ปีที่แล้ว +1

    Thanks alot Derrick, you are the best.❤❤

  • @minevr5839
    @minevr5839 4 ปีที่แล้ว

    Learning Python right now. Keep up the great work. I like your channel.

  • @samijuju9728
    @samijuju9728 3 ปีที่แล้ว

    Tanks Derrick i’m fan of your work 👍

  • @zma314125
    @zma314125 2 ปีที่แล้ว

    Thank you, Derrick!

  • @Guilopes99
    @Guilopes99 4 ปีที่แล้ว +9

    Thanks!
    As a python newbie and advanced Excel user, I struggle to learn Python as I'm very stuck to excel logic. Would be great to have a tutorial that shows how to do most of Excel data wrangling but better and quicker with python! Thanks!

  • @johnmcmanus6719
    @johnmcmanus6719 ปีที่แล้ว

    This video was so quick I didn't have time to thank you 👍

  • @duvanm2483
    @duvanm2483 4 ปีที่แล้ว

    Thank you so much, bro. This will be very useful for my project that I plan to implement in my job!

  • @douglaskwesie5697
    @douglaskwesie5697 4 ปีที่แล้ว

    @Derrick Sherrill, u are the man!

  • @sekar887
    @sekar887 ปีที่แล้ว

    Super thanks for sharing the code in description

  • @ssam7195
    @ssam7195 4 ปีที่แล้ว

    Thanks Derrick 👍. Today I'm going to try this excercise in one of my regular task.

  • @soeaung1984
    @soeaung1984 3 ปีที่แล้ว

    Excel Sumifs function from different Sheet. Thank you very much, Mr. Derrick.

  • @merryjoy48
    @merryjoy48 5 ปีที่แล้ว +1

    Hope you do more of the videos on python. Your videos have been really helpful to me (a beginner).

  • @SS-cn2td
    @SS-cn2td 3 ปีที่แล้ว

    Derrick, this is really helpful, it's my daily work job to find out such cases, till now I was using index match. But now I will do with the method u showed here. Thanks.

  • @PM-cs6jq
    @PM-cs6jq ปีที่แล้ว

    My friend, What a nice person you are and a great teacher 👏👏👏

  • @logannon
    @logannon 2 ปีที่แล้ว

    Been searching the world wide web for 4 hours on how to do this, and this is the only video that correct depicts what I needed. Thank you so fucking much!

  • @fernandor4340
    @fernandor4340 3 ปีที่แล้ว

    Pretty good video, as a begginer I could see some useful functions well explained.

  • @virendraupadhye150
    @virendraupadhye150 2 ปีที่แล้ว

    Just started to learn Python. Thanks very good explanation

  • @rhettsmedia
    @rhettsmedia 4 ปีที่แล้ว

    Thank you very clear very concise very good I will watch every video you make

  • @357qw
    @357qw 3 ปีที่แล้ว

    Very very well explained. Thanks a lot Brother. I count on your channel here after :)

  • @vio-noob_6737
    @vio-noob_6737 5 ปีที่แล้ว +25

    This channel is criminally under subscribed. Very very helpful!!

    • @vio-noob_6737
      @vio-noob_6737 3 ปีที่แล้ว

      Chris Keo no, you

    • @fernandor4340
      @fernandor4340 3 ปีที่แล้ว

      Yeah!

    • @josueespinosolano6974
      @josueespinosolano6974 3 ปีที่แล้ว

      Agree hahaha I have created a lot of Python automated codes in my job thanks to Derrick

  • @vikassharma071107
    @vikassharma071107 4 ปีที่แล้ว

    Very helpful. Thanks for this.

  • @no0gon
    @no0gon 4 ปีที่แล้ว

    i always use kind this vlookup in SAS, like left join and now i can do this thing with python. thank your guide again sensei

  • @patrickwheeler7107
    @patrickwheeler7107 3 ปีที่แล้ว

    I love how you can go across data sources.

  • @dieguin311
    @dieguin311 3 ปีที่แล้ว

    Thanks dude.
    This really help me.
    Saludos!

  • @maw4855
    @maw4855 4 ปีที่แล้ว

    smart guy! high quality video seriosly

  • @delta-game
    @delta-game 4 ปีที่แล้ว +2

    Thankyou, finally found some decent content with someone who can speak english clearly. You are a saviour!

  • @drezim2001
    @drezim2001 4 ปีที่แล้ว

    I look forward to more of your videos. I have screwed up some many formulas in excel.

  • @edileimoura
    @edileimoura 4 ปีที่แล้ว

    Thanks for sharing. Congratulations on your talent

  • @lxlx19
    @lxlx19 4 ปีที่แล้ว

    You save me! tks....greetings from Brazil

  • @kenifk1446
    @kenifk1446 4 ปีที่แล้ว

    Superb bro. Keep doing more videos like this😎

  • @loveyoutube22
    @loveyoutube22 4 ปีที่แล้ว

    Very helpful, thank you

  • @JDiGi36
    @JDiGi36 5 ปีที่แล้ว +1

    Nice Job. Thanks

  • @expresstutorial3255
    @expresstutorial3255 3 ปีที่แล้ว

    you area amazing bro!!!!

  • @tejaspawar3233
    @tejaspawar3233 3 ปีที่แล้ว

    Hi Derrick
    Your explanation style and codes are simple and coo😎😎l gone through many videos on TH-cam but none were practical and simple thanks bro keep it !!!👍👍👍
    Have become your fan by just one vedio will explore all your content thanks again 🎉🎉🎉

  • @adipai
    @adipai 4 ปีที่แล้ว

    Very Helpful !!

  • @SalehGoodarzian
    @SalehGoodarzian 2 ปีที่แล้ว

    Very good exercise, thanks for this great video. I appreciate and wish you the best

  • @abrammakgalemele3491
    @abrammakgalemele3491 4 ปีที่แล้ว +1

    Tx Derrick. To SQL users, that's a LEFT JOIN.

  • @Rita00007
    @Rita00007 2 ปีที่แล้ว

    Amazing!

  • @manibhushanabhishek2876
    @manibhushanabhishek2876 4 ปีที่แล้ว

    You saved me. Thank You

  • @dvsrkumar13
    @dvsrkumar13 5 ปีที่แล้ว +19

    Hi Derrik,
    This was a nice video.
    Could you please make a video on how to compare two excel files and highlight the differences in a third excel file?
    Could you please help. :)

  • @Perspicacious_pi
    @Perspicacious_pi 3 ปีที่แล้ว

    great content very concise

  • @urielronaldo196
    @urielronaldo196 3 ปีที่แล้ว +1

    This channel should have +1M subscribers. I am an economist from Mexico City and Derrick is my inspiration for keeping learning Python!

  • @vivekkaranath7706
    @vivekkaranath7706 4 ปีที่แล้ว

    excellent video..really helpful

  • @currentbulb9955
    @currentbulb9955 4 ปีที่แล้ว

    Thanks Derrick :)

  • @catalinim4227
    @catalinim4227 4 ปีที่แล้ว

    thanks for this, widens the solutions range... a faster formula is index+lookup, to eliminate human errors we can use macros. I know xlsx can't have macros but we can quickly write one in the personal macros and use it on any tybe of wb

  • @wasimakram6669
    @wasimakram6669 4 ปีที่แล้ว

    Derrick Sherrill I love you 😍

  • @data_dave
    @data_dave ปีที่แล้ว

    good VOD

  • @thomasfung3205
    @thomasfung3205 4 ปีที่แล้ว

    Great content.

  • @evanshlom1
    @evanshlom1 3 ปีที่แล้ว

    Great video. Need to look up regex

  • @schummy3000
    @schummy3000 4 ปีที่แล้ว

    you make me decide to learn Phyton !

  • @riseagain4973
    @riseagain4973 3 ปีที่แล้ว

    You ARE awesome

  • @diegoojeda6399
    @diegoojeda6399 3 ปีที่แล้ว

    excelente video muy util

  • @rajmahal8429
    @rajmahal8429 3 ปีที่แล้ว

    Thank You!!

  • @anupk1234
    @anupk1234 3 ปีที่แล้ว

    Thank you

  • @AliTwaij
    @AliTwaij 2 ปีที่แล้ว

    Brilliant

  • @ryanrumsey2830
    @ryanrumsey2830 3 ปีที่แล้ว

    Hello Derrick .. I have learned so much from watching your videos.
    Do you do any one on one training or a little Q&A ?

  • @loveSG999
    @loveSG999 4 ปีที่แล้ว +6

    Hey Derrick, any chance you could include these cool video tutorials onto your python course on Udemy? By the way, I’m a big fan of your work👍👍

  • @jesusloaiza3032
    @jesusloaiza3032 4 ปีที่แล้ว

    Vielen Dank!!

  • @lshankar83
    @lshankar83 4 ปีที่แล้ว +1

    Hi Derrick, the common assumption which everyone makes is that, they assume we always work on a new excel file and the merged data we put it in last columns.. But i have an old excel file and from which i need information from a specific column. Using the vlookup its easy but python merge (the one you described) i get the entire data from the old file.. here are the steps
    1. two files : old.xlsx which has 10 columns and column 3 is having sales data & the new.xlsx where i need bring in the last month sales in a newly inserted column.
    2.need only only column data from old.xlsx to the new file. lets say, the location key is common and last month sales
    not sure if the above describes the requirement well.. not sure how inner join, outerjoin helps but dont understand them

  • @enggsushant
    @enggsushant 5 ปีที่แล้ว +2

    Please make a video of appending one excel data to another excel data with similar columns. And then writing it to a new workbook

  • @lovelyimranahamed
    @lovelyimranahamed 3 ปีที่แล้ว

    This is great. I want to compare 2 excel workbook and print all the differences.. Can you please make video on this?

  • @learn4geek
    @learn4geek 4 ปีที่แล้ว

    Good sir

  • @robertcliffort2354
    @robertcliffort2354 2 ปีที่แล้ว

    great.

  • @shanaebrown1563
    @shanaebrown1563 3 ปีที่แล้ว

    Would love a video showing how to loop through each sheet in a csv or a excel file

  • @NB-tk7tn
    @NB-tk7tn 5 ปีที่แล้ว

    Awesome video, I just subscribed. What songs are you playing in the beginning/end?

  • @nenadmylink
    @nenadmylink 4 ปีที่แล้ว

    awesome

  • @privatenumber8593
    @privatenumber8593 3 ปีที่แล้ว

    Hey derrick thanks its really informative .. Can you also tell in some video how to use filter using pandas and how to create new column using exiting value in same sheet ....

  • @n2201
    @n2201 4 ปีที่แล้ว

    Thank you Derrick for this wonderful chanel! Extremely useful. I have one set of email address in one workbook and another set of email address in second workbook, I want to send email to all the people who are in the first workbook but not in the second workbook. What method should I look for?

  • @duvanm2483
    @duvanm2483 4 ปีที่แล้ว +1

    Hi bro. Could you please make a video where you explain how to select values from different rows and colums to create a new column. For instance, in the first row select the column 3 in the second row column 5 and so on. I would really appreciate it!

  • @nhanhuynh2443
    @nhanhuynh2443 5 ปีที่แล้ว +3

    Hi Derrick, many thanks for this great video! This is actually helping me a lot with my daily tasks. I have a request for a video on how to use Python to recognize a text pattern in a spreadsheet. Then print a string in a new column accordingly. For example, if a text pattern start with "PM-" in a string "PM-AVdjslqo" we print "Project Manager" in the column next to it. Thanks in advance if you can help me with it.

    • @CodeWithDerrick
      @CodeWithDerrick  5 ปีที่แล้ว

      Great suggestion! Would be a handy tool to have. I'll see what I can code up!

  • @bijoysaraf650
    @bijoysaraf650 4 ปีที่แล้ว

    Simply outstanding!
    Liked & subscribed.
    Q: Can you suggest how we can do index and match or index and aggregate functions of Excel using Pandas & Numpy?
    Thank you for sharing!

  • @rasoulkhoshravan5912
    @rasoulkhoshravan5912 3 ปีที่แล้ว

    Dear Derrick Thanks for informative video. I came to know about the usage of Python in Excel through your videos. It is wonderful. If I want to learn Python in Excel, where should I start from? Which book or site do you recommend? DO you have website for python?

  • @ricardocabrera8344
    @ricardocabrera8344 4 ปีที่แล้ว +1

    Great video, but it would be better if the IDs name would have been "ID_A", "ids_b" or something like that to help us newbies better.

  • @razorfisher3123
    @razorfisher3123 3 ปีที่แล้ว

    Can u show (at some point) how to use with chrontabs to automate? Thank you Derrick!!

  • @BAL31m89
    @BAL31m89 ปีที่แล้ว

    Can you please share one by one all the excel functions and create one series as playlist. That will be great

  • @percy1025
    @percy1025 4 ปีที่แล้ว

    Hi Derrik, good video and happy to learn from you. One quick question, how to copy and paste one df to a specific position (not start from cell A1 but like cell B50) of an excel? hope you could help with it! Thank you!!!

  • @pipepi4888
    @pipepi4888 4 ปีที่แล้ว

    I love you.

  • @tessvercammen4784
    @tessvercammen4784 4 ปีที่แล้ว

    Thank you so much! This really helped

  • @emart7437
    @emart7437 4 ปีที่แล้ว

    Great video. Thanks for sharing your experience. I'm new to Python, programming. My question is how do I implement the code? How do I run the code? Do you install it on Excel? Where does the code run from? I hope my question makes sense. Thank you for your help.

    • @adrianx.3775
      @adrianx.3775 4 ปีที่แล้ว +1

      There is no relation to excel besides the output. You don't even need excel installed. It's just Python and a python code editor plus pandas Python module.

  • @gregorydubois8468
    @gregorydubois8468 2 ปีที่แล้ว

    Hi, I'm starting with Python and your videos are very helpful.
    I have a question: how can we apply the merge method in the A sheet directly without creating a third file ? Thank you!

  • @melancenziza239
    @melancenziza239 3 ปีที่แล้ว

    Hi Derrick,
    Thank you so much. I absolutely adore your tutorials!
    Quick question - Have you ever come across cases in your work where you needed to execute a lookup with multiple criteria? i.e. where you've used multiple columns for the lookup instead of just matching against one column.
    Please let me know if you've got any tricks or if you already have a tutorials you can point me to.
    Thanks a lot in advance!

    • @richynero
      @richynero 3 ปีที่แล้ว +1

      If you have multiple criteria just make a new column that concatenates those into one and those that as pseudo super key.

    • @melancenziza239
      @melancenziza239 3 ปีที่แล้ว

      @@richynero Awesome. Thanks for that

  • @nareshvadlamudi
    @nareshvadlamudi 4 ปีที่แล้ว

    Hi Derrick, could you please update a video on his to download files from Outlook inbox/subfolder to local system. Thank you

  • @partymaschine92
    @partymaschine92 3 ปีที่แล้ว

    Hey, nice work! Thanks a lot for your effort! I‘m completely new to python. I wonder why we don‘t have to insert a full path to the excel files here or do I have to and you just skipped the info to keep the example easier?

  • @SofonToSafes
    @SofonToSafes 3 ปีที่แล้ว

    Where can I find the A.xlsx and B.xlsx that you use above? Thanks a lot! Excellent job!

  • @kumarsunil1861
    @kumarsunil1861 4 ปีที่แล้ว

    This is of great help!
    Here I subscribed...
    One request - could you please advise how can we split a Excel file into multiple by number of rows. For example: File A contains 500 rows then 5 files like A1,A2,A3,A4,A5 to be created 100 rows each?

  • @razorfisher3123
    @razorfisher3123 3 ปีที่แล้ว

    Thank you for sharing! Is there a Python function that would allow this script to automatically run in a recurring frequency? I.e. would it be a parenthetical command that would enclose the entire script? Thanks again!