Question: I have a 2-D numpy array each row of which consists of three elements - ['dataframe\_column\_name', 'dataframe\_index', 'value'].
Now, I tried populating the pandas dataframe using iloc double for loop but it is quite slow. Is there any faster way of doing this. I am a bit new to pandas, so apologies in case this is something very basic.
Here is the code snippet :

```
my_nparray = [['a', 1, 123], ['b', 1, 230], ['a', 2, 321]]
for r in range(my_nparray.shape[0]):
    [col, ind, value] = my_nparray[r]
    df.iloc[col][ind] = value

```

This takes a lot of time when my\_nparray is large, is there any other way of doing this?

Initially assume that I can create this data frame :

```
  'a' 'b'
1 NaN NaN
2 NaN NaN

```

I want the output as :

```
  'a' 'b'
1 123 230
2 321 NaN

```

Answer: 
Wouldn't this work:

```
 def convert_to_klist(map) do
   Enum.map(map, fn({key, value}) -> {String.to_existing_atom(key), value} end)
 end

```
You can use the `Keyword.new` function and pass in a transform function as the second argument.

```
Keyword.new(%{"browser_name" => "Chrome", "platform" => "linux"}, fn {k,v} -> {String.to_existing_atom(k), v} end)
> [browser_name: "Chrome", platform: "linux"]

```

Although this is basically equivalent to the accepted answer from @NiteRain, I think it's a bit more explicit and shows future readers of your code your intentions.

See: <https://hexdocs.pm/elixir/Keyword.html#new/2>