I have a pandas dataframe like this:

```
index  country   value1   value2   value3
  0      USA      6         5        4
  1      USA      4         7        3
  2      USA      3         2        1
  3      CAN      4         5        7
  4      CAN      10        8        6

```

I want to convert this to a column-oriented dataframe like below for each value (i.e. value1, value2 or value3)

The first dataframe for value1 should look like this:

```
index   USA     CAN
  0      6       4 
  1      4       10
  2      3       NaN

```

I have tried this code

```
column = ['USA', 'CAN']
df_value1 = pd.DataFrame(columns=column)
temp = df['value1'].where(df['country']=='USA').dropna()
df_value1['USA'] = temp
temp = df['value1'].where(df['country']=='CAN').dropna()
pd.concat([df_value1, temp], axis=1, ignore_index=True)

```

When I concatenate along the column (axis=1) since CAN values start from row 3 I get the resulting df\_vaue1 dataframe like this:

```
index   USA     CAN
  0      6       NaN
  1      4       NaN
  2      3       NaN
  3     NaN       4
  4     NaN       10

```

But I want the df\_value1 dataframe like this:

```
index   USA     CAN
  0      6       4 
  1      4       10
  2      3       NaN

```

How can I achieve this?