Hui
Hui

Reputation: 3

split one column into two and combine in pandas

I have this data in excel:

enter image description here

I'd like to have it read in pandas dataframe like the following:

enter image description here

Upvotes: 0

Views: 64

Answers (1)

Quang Hoang
Quang Hoang

Reputation: 150735

You can do:

df = pd.read_excel('file.xlsx')

df = pd.DataFrame(df['V1'].values.reshape(-1,2), columns=['V1','Value'])

Output:

  V1 Value
0  A     2
1  b     4
2  c     8

Upvotes: 2

Related Questions