1

The problem is a little hard to explain. I have one dataset "Tab1" that consists of 110 columns. This is the data of online experiments. The second table "Tab2" consist of the results of the experiments of "Tab1" which has 20 columns. The column "exp_num" is common in both of these tables while the rest of the columns are different.

To take an example, I have 20 experiments and each experiment has 6 records i.e. total of 120 records in "Tab1". Let's take one experiment 'exp1' as an example. After the 6th record (last result of this experiment) the result of this experiment from "Tab2" will be appended. After that next experiment 'exp2' and after the last record of 'exp2' the result of 'exp2' from 'Tab2' is again appended and so on.

The structure should look like this:

image

Data in yellow mark is from "Tab1" and gray one is from "Tab2"

Timus
  • 10,974
  • 5
  • 14
  • 28
  • Does this answer your question? [Use a list of values to select rows from a Pandas dataframe](https://stackoverflow.com/questions/12096252/use-a-list-of-values-to-select-rows-from-a-pandas-dataframe) – Ran A Sep 20 '22 at 11:05
  • Please [do not post images data etc.](https://stackoverflow.com/help/how-to-ask), add the information as text (within code fences etc.) instead. And please add a [MRE](https://stackoverflow.com/help/minimal-reproducible-example) (also look [here](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples)) that replicates your problem. – Timus Sep 20 '22 at 14:31

1 Answers1

0

i think what you want is actually a concatination or pandas.concat.

heres a full example.

import pandas as pd
import numpy as np

d1 = {'exp_num': ['aw23','aw23','aw23','aw23','aw23'], 'colA': [2,2,2,2,2], 'colB': [3,3,3,3,3], 'colC': [4,4,4,4,4]}
df1 = pd.DataFrame(data=d1)

d2 = {'exp_num': ['aw23','aw23'], 'colD': [1,2], 'ColE': [3,4]}
df2 = pd.DataFrame(data=d2)

to show the example dataframes

df1.head(5)

df2.head(5)

here's the concat and the results

df3 = pd.concat([df1,df2], ignore_index=True)
df3.head(10)

just for knowledge share. The easiest way to find what you need is probably the pandas cheat sheet https://pandas.pydata.org/Pandas_Cheat_Sheet.pdf#

if thats the right answer pls mark it. thx :)

best Faby

fabigr8
  • 11
  • 1