0

a*.csv

 D        A     B     E       F

park    KOREA   1   SUM1    hello1

michel  France  3   SUM3    hello3

park2   USA     4   SUM4    hello4

b*.csv

A       B   C

KOREA   1   2020

KOREA   2   177

France  3   2020

USA     4   43

SPAIN   7   67

example

 D        A     B    C(add)  E        F

park    KOREA   1   2020    SUM1    hello1

michel  France  3   2020    SUM3    hello3

park2   USA     4   3       SUM4    hello4

park3   SPAIN   7   67      SUM5    hello5

park4   USA     8   177     SUM6    hello6

park5   KOREA   11  584     SUM7    hello7

park6   DEN     5   43      SUM8    hello8

I edited the content and then restored it because the answer didn't solve it and I solved it myself

I'll end the question after commenting it solution

but I chose one answer to close this question

2
  • 1
    Hi, and welcome to Stack Overflow. This is a Q&A site, not a forum. If you solved your own question - great! but don't edit it to say "solved"; either close it (by accepting another answer, by answering your own question, or just by closing it) - or if the question is not interesting, delete it. Commented May 21, 2020 at 11:40
  • @Itamar Mushkin Thank you for explain about Stack Overflow, I will tried just by closing and delete it but I can't it's possible?? Commented May 21, 2020 at 13:02

1 Answer 1

1

I think you can use the merge() function.

try_a = glob.glob('a*.csv')
try_b = glob.glob('b*.csv')
lst_a = []
lst_b = []
for (i,j) in zip(try_a,try_b):
 lst_a.append(i)
 lst_b.append(j)
df_a = pd.concat(lst_a)
df_b = pd.concat(lst_b)
df_a.set_index('d', inplace= True)
df = pd.DataFrame.merge(df_a,df_b, how = 'inner', left_index = True).reset_index()

I hope it works!!

Sign up to request clarification or add additional context in comments.

1 Comment

It's have a error messages -> Exception has occurred: AttributeError 'list' object has no attribute 'set_index'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.