how to match row names of two files quickly using python
0
0
Entering edit mode
3.5 years ago
szp770 ▴ 10

Now I have two files, file1 has a column of names as shown below(billions of lines):

name1
name2
name3
name4

file2 also has the column of names and some other information (not all names in file1 show up in file2, but all names in file2 show up in file1):

file2 is like this:

name1   18
name4   90

Now I want to fill file1 with the second column of file2, if the name is not in file2, then fill 0 in that row in file1, the result should be like this:

name1   18
name2   0
name3   0
name4   90

Because there are billions of lines in each file, is there any way to do this very quickly? Thanks!

python pandas • 610 views
ADD COMMENT

Login before adding your answer.

Traffic: 1698 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6