# Re: Re: \[personal kdb+\] dictionary with flip

**URL:** <https://forum.kx.com/t/re-re-personal-kdb-dictionary-with-flip/12131>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [April 27, 2021, 8:01pm UTC](https://forum.kx.com/t/re-re-personal-kdb-dictionary-with-flip/12131 "2021-04-27T20:01:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unterrainer\_ale1](https://avatars.discourse-cdn.com/v4/letter/u/9dc877/32.png) [@unterrainer\_ale1](https://forum.kx.com/u/unterrainer_ale1)\
**Post date:** [April 27, 2021, 8:01pm UTC](https://forum.kx.com/t/re-re-personal-kdb-dictionary-with-flip/12131/1 "2021-04-27T20:01:00Z")

</div>

Hi,  
I believe you a referencing to the example here: https://code.kx.com/q4m3/8\_Tables/#81-table-definition

### 8.1.1 Review of Table as Column Dictionary

This says that a table is a flipped&nbsp;column dictionary. "When a dictionarys value items are all same-length lists, it is a&nbsp;_column dictionary_." (As per definition here at the end of this page:&nbsp;https://code.kx.com/q/basics/dictsandtables/)&nbsp;

when you select 1 row of a table, you no longer have a column dictionary, but a simple dictionary, which you can't flip.&nbsp;

q)t:flip `name`iq!(`Dent`Beeblebrox`Prefect;98 42 126)

q)t

name &nbsp; &nbsp; &nbsp; iq

* * *

Dent &nbsp; &nbsp; &nbsp; 98

Beeblebrox 42

Prefect &nbsp; &nbsp;126

q)t 0

name| `Dent

iq &nbsp;| 98

q)

Now, it's worth mentioning (and actually important to remember), that a table is actually nothing else than a list of dictionaries. q is smart enough to use the keys of the dictionaries as column names (they obviously need to be the same). You can see this by trying the following:

q)(t 0;t 1)

name &nbsp; &nbsp; &nbsp; iq

* * *

Dent &nbsp; &nbsp; &nbsp; 98

Beeblebrox 42

you get a table with two rows (the first two from the original table). Knowing this, you could get a 1 row table doing the following

q)enlist t 0

name iq

* * *

Dent 98

One more thing about tables, we know that tables are flipped column dictionaries, but q actually doesn't flip (reorder the data) but only records that the data should be displayed as a table. You can see this by inspecting the table using 0N!&nbsp;

q)0N!t

+`name`iq!(`Dent`Beeblebrox`Prefect;98 42 126)

name &nbsp; &nbsp; &nbsp; iq

* * *

Dent &nbsp; &nbsp; &nbsp; 98

Beeblebrox 42

Prefect &nbsp; &nbsp;126

The&nbsp;+ in front of the dictionary is k-code for the flip function in q.&nbsp;

q)flip

+:

(In order to keep things simple ignore the : in the above code snippet, it's k code and it's best to look at q code for now).

Hope this helps.

Alexander
