Skip to content Skip to sidebar Skip to footer

Mapping Multiple Dataframe Based On The Matching Columns

I have 25 data frames which I need to merge and find recurrently occurring rows from all 25 data frames, For example, my data frame looks like following, df1 chr start end n

Solution 1:

Using the glob module, you can use

import os
from glob import glob

path = 'Fltered_vcfs' 
f_names = glob(os.path.join(path, 'vcf_filtered*.*')) 

Then, your dictionary can be created with dictionary comprehension using

import pandas as pd

 {os.path.splitext(os.path.split(f_name)[1])[0]: pd.read_csv(f_name,sep='\t') for f_name in f_names}

Post a Comment for "Mapping Multiple Dataframe Based On The Matching Columns"