0

I am trying to concatenate multiple files, but I get the following error:

raise ValueError("Reindexing only valid with uniquely valued Index objects")
ValueError: Reindexing only valid with uniquely valued Index objects

My code:

import pandas as pd
import glob
from functools import reduce
path = r'/path/to'
all_files = glob.glob(path + "/*.txt")
my_dfs = [pd.read_csv(file, sep='\t').set_index(['POS', 'CHROM', 'REF', 'ALT']) for file in all_files]
df = pd.concat(my_dfs, axis=1)
df.reset_index(inplace=True)
result_df = df.fillna('.')
result_df.to_csv('out.txt', sep="\t", index=False)

It this because I have duplictes? how to osolve this problem?

user3224522
  • 1,119
  • 8
  • 19

0 Answers0