How does python extract data from multiple specified samples?

the available data is as follows (the real situation is about hundreds of thousands of rows):

clipboard.png

for example, there is another file p.txt with a column as follows:
"8240004146789610
8240004356417597
...
8240004146757344 "
I need to extract the number in the fourth column p.txt from the data. Is there any fast method (the method is not limited to pandas)?
is actually a sampling process in which a specified sample is taken and the fourth list is the number in the specified file.

the idea now is to loop in p.txt, then use pandas to read the original data, and then extract the number of the fourth column = = loop. Is there a faster way?

May.20,2022

consider using pandas's apply, minus the steps of p.txt loop and subsequent matrix stitching.
that is, read the data in p.txt and convert it to a list such as P, then read the original data with pandas, and execute:

df[df[<>].apply(lambda x: x in P)]
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bf5b-2c2ed.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bf5b-2c2ed.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?