Question: I have this DF: `Columns: df=pd.DataFrame(columns=["a","b","c","d","e","f","g"])`

and this : `data=["a:42","b:43","c:22","d:41","a:21","b:14" ,"c:12","e:14" ,"f:7","a:0" ,"d:1","f:3","a:6" ,"b:0","c:9","g:8" ]`

I need

```
for d in data:
   spli=d.split(":")
   colum=spli[0]
   value=spli[1]
   df[colum] = value

```

waiting for this result

```
["a"  "b"   "c"   "d"   "e"    "f"    "g"  ]
  42   43    22    41   nan    nan     nan
  21   14    12    nan   14     7      nan
  0    nan   nan    1    nan     3     nan
  6     0     9    nan   nan   nan      8

```

Answer: 
You need a non-empty df to set a column to a certain value. You can create a new df for a row with all nans, and then set column values. You can test whether you need a new row by comparing the numeric value of a, b, c ... with ord(). Append the df\_row to the master df for each new row, and once at the end of the loop. Here's one way to do it:

```
df = pd.DataFrame(columns=["a", "b", "c", "d", "e", "f", "g"])

data = ["a:42", "b:43", "c:22", "d:41", "a:21", "b:14", "c:12", "e:14", "f:7", "a:0", "d:1", "f:3", "a:6", "b:0", "c:9", "g:8"]

df_this_row = pd.DataFrame([[np.NAN, np.NAN, np.NAN, np.NAN, np.NAN, np.NAN, np.NAN]], columns=["a", "b", "c", "d", "e", "f", "g"])
first_col, first_val = data[0].split(':')
df_this_row[first_col] = int(first_val)

for i in range(1, len(data)):
    col, val = data[i].split(':')
    prev_col = data[i-1].split(':')[0]
    if ord(col) <= ord(prev_col):     
        # you are in next row, eg f was previous col, and you have col b
        df = df.append(df_this_row)
        df_this_row = pd.DataFrame([[np.NAN, np.NAN, np.NAN, np.NAN, np.NAN, np.NAN, np.NAN]], columns=["a", "b", "c", "d", "e", "f", "g"])
    df_this_row[col] = int(val)

df = df.append(df_this_row).reset_index(drop=True)

print(df)
#     a    b    c    d    e    f    g
# 0  42   43   22   41  NaN  NaN  NaN
# 1  21   14   12  NaN   14    7  NaN
# 2   0  NaN  NaN    1  NaN    3  NaN
# 3   6    0    9  NaN  NaN  NaN    8

```
Is it posible to convert your data to a list of dictionary like:

```
data = [{"a":42,"b":43,"c":22,"d":41}, 
 {"a":21,"b":14 ,"c":12,"e":14 ,"f":7},
 {"a":0 ,"d":1,"f":3},
 {"a":6 ,"b":0,"c":9,"g":8}]

```

Then, you can create a dataframe by:

```
df=pd.DataFrame(data).

```