vlookup Should be excel There are many functions used in , I just got in touch excel When I was young , Anyway, I think this function is very magical , It saves a lot of things .
But after a long time, I found that vlookup There are too many restrictions ...
* The first pain point ： Only to the right --> look for , If you want to look to the left , The most stupid way is to find out what you are looking for column Copy it to the left , That's what I'm like anyway . that match ,
index The combination of , I haven't remembered it yet |||
* The second biggest pain point ： Only one project can be found , If there are double or multiple conditions , It's like an array , bar ?
* Third pain point ：excel If the watch is too big , It's time to wait , Move the mouse a little , It could crash , Then repeatedly shut down the boot restart , Mainly rely on rp.
So I just got in touch python The first thing I want to explore is python Can it be realized excel. Now I'm going to make a grand science popularization python How did it happen , Let us feel that python It's more practical , Learn step by step .
The first step , from anaconda open python
Step two , input import pandas as pd Then enter
pandas It's a third-party library , For the moment, it can be understood as a tool library for us to invert tables . Basically excel The usual operations , stay python Just use this in it .
The third step , Make two forms by yourself , For the convenience of reading , I typed Chinese in some places , Whatever you want .
Just remember python I care about case ,name and Name It's not the same thing . After entering the carriage return, it will automatically go to the next line .pd.DateFrame It means to produce a table in brackets .
Step four , use mergy; Even if I didn't touch it at all python, from merge English in that line , How much can you guess is by name tableB The content of the tableA What do you mean .
* If tableC It's a mess “ Lao Wang ”, What is the effect ,
Lao Wang is gone , The reason is because of me merge My condition is only to find tableA yes , we have , Because I used it how = 'left', You can try various combinations .
Tips ：how Can be equal to left, right, inner, outer
* If ,hobby stay name To the left of ,merge I don't care about that at all , We can still find out , That's the solution excel vlookup I can only look for the pain point on the right
The result is the same
* Again if , One might ask if there are other columns in the second table , What will the effect be , You can try it first .
The result should be like this ,
Homework, You can feel for yourself how='left' / 'right' / 'inner' / 'outer' The difference between .