Question: I have list of Active Directory Users's Guid, I need to load a set of properties of those users for a specific reporting. To do this, if we make a bind for each Guid, then it will be a costly one. Whether with DirectorySearcher, can we provide multiple Guid(say 1000) as filter and load the properties?.

Answer: 
TL;DR
=====

```
>>> import pandas as pd
>>> df = pd.DataFrame({'Position':[1,2,3,4,5], 'Letter':['a', 'b', 'c', 'd', 'e']})
>>> dict(sorted(df.values.tolist())) # Sort of sorted... 
{'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}
>>> from collections import OrderedDict
>>> OrderedDict(df.values.tolist())
OrderedDict([('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5)])

```

In Long
=======

Explaining solution: `dict(sorted(df.values.tolist()))`

Given:

```
df = pd.DataFrame({'Position':[1,2,3,4,5], 'Letter':['a', 'b', 'c', 'd', 'e']})

```

[out]:

```
 Letter Position
0   a   1
1   b   2
2   c   3
3   d   4
4   e   5

```

Try:

```
# Get the values out to a 2-D numpy array, 
df.values

```

[out]:

```
array([['a', 1],
       ['b', 2],
       ['c', 3],
       ['d', 4],
       ['e', 5]], dtype=object)

```

Then optionally: 

```
# Dump it into a list so that you can sort it using `sorted()`
sorted(df.values.tolist()) # Sort by key

```

Or:

```
# Sort by value:
from operator import itemgetter
sorted(df.values.tolist(), key=itemgetter(1))

```

[out]:

```
[['a', 1], ['b', 2], ['c', 3], ['d', 4], ['e', 5]]

```

Lastly, cast the list of list of 2 elements into a dict. 

```
dict(sorted(df.values.tolist())) 

```

[out]:

```
{'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}

```

---

Related
=======

Answering @sbradbio comment:

If there are multiple values for a specific key and you would like to keep all of them, it's the not the most efficient but the most intuitive way is:

```
from collections import defaultdict
import pandas as pd

multivalue_dict = defaultdict(list)

df = pd.DataFrame({'Position':[1,2,4,4,4], 'Letter':['a', 'b', 'd', 'e', 'f']})

for idx,row in df.iterrows():
    multivalue_dict[row['Position']].append(row['Letter'])

```

[out]:

```
>>> print(multivalue_dict)
defaultdict(list, {1: ['a'], 2: ['b'], 4: ['d', 'e', 'f']})

```
Here are two other ways tested with the following df.

```
df = pd.DataFrame(np.random.randint(0,10,10000).reshape(5000,2),columns=list('AB'))

```

using `to_records()`

```
dict(df.to_records(index=False))

```

using `MultiIndex.from_frame()`

```
dict(pd.MultiIndex.from_frame(df))

```

Time of each.

```
24.6 ms ± 847 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
1.86 ms ± 11.6 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

```