This is the first use python It's a practical project , If there is something wrong , Please correct me !

<> target :

use python Put the table 1 Insert the corresponding data in the table 2, realization excel In vlookup function

<> preparation :

a. numpy library ,pandas library ( Environment building is really important )

b. A table that needs to be filled with data

c. Existing data table

Results display :

<> Operation steps

step 1: Read the contents of two tables
import pandas as pd # Regional information table df_location = pd.read_excel(
"D:\python\\numpy\\test1\ Regional information table .xlsx" ) df_location.head() # Database export table df_number =
pd.read_excel("D:\python\\numpy\\test1\ Data collection table .xlsx") df_number.head()
( Don't put files on the desktop , Don't ask me why ,QAQ)

step 2: You only need to use some of the columns in the table
# Only a few columns of the second table are filtered ( Select only the urban areas and users in Table 2 ) df_number = df_number[[ " urban district ", " Number of users "]] df_number.
step 3: realization vlookup The most important step in a function – Determine whether the data in two tables match
df_merge = pd.merge(left=df_location, right=df_number, left_on=" urban district ", right_on=
" urban district ") df_merge.head()
step 4: Merged exported data table
df_merge.to_excel("d:\\python\\numpy\\test1\\ Merged data table .xlsx", index=False)
That's all , Do not understand or feel that there are problems to improve , Welcome to leave a message below . I am also Xiaobai , Writing for the first time , I hope you can support me !

©2020 ioDraw All rights reserved
Java exercises 1: Simply define a car class New photo album app launched by Microsoft : Using cross platform framework React Native to write Chapter two Fundamentals of programming Programming exercises pandas Time order of webpack Code segmentation import()Vue slot slot: Default slot , Named slot , Scope slot Fundamentals of data analysis ——R language ( Processing missing values )C++ Implementation of matrix meteor shower effect PostMan Advanced Usage , Interface MD5+Secret autograph Sign The 12th Blue Bridge Cup B group C/C++ Provincial competition