-1

I have a set of data with 2 columns: Column1 = Hex Code and Column2= Current (A).

The data in Column1 is Hex Code, 27 different codes which repeats and for each Hex Code have Current (A) value on Column2.

I want to pick a set of 27 data points from Column1 & Column2 and place them into Coulmn3 & Column4.

Can someone help me to achieve this?

This is how the initial data looks

This is how i would like the data to be arranged

  • welcome to stackoverflow, kindly look into how to prepare a proper pandas question so we can help you better (hint don't post images of data) https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples – Jimmar Mar 24 '21 at 20:13

1 Answers1

0

I am going tho show you my code. But I want to tell that you can not have repeating columns names. We suppose data is the name of your original dataset:

import pandas as pd

col_name1=data.columns.values[0]
col_name2=data.columns.values[1]

two_columns = data[[col_name1,col_name2]][0:27].values

two_columns = pd.DataFrame(two_columns,columns=[col_name1+'_1',col_name2+'_2'])

df = data.iloc[0:27,:]

df = df.join(two_columns)

print(df)