# [Numpy-discussion] Extracting column vectors from matrix.

Andrew Nesbit alnesbit at students.cs.mu.OZ.AU
Thu Sep 4 02:59:05 EDT 2003

```Say that I have a rank-2 array (matrix) of shape (m,n).  Call it A.

When extracting column vectors from A, I often want to keep the result
as a rank-2 column vector (for subsequent matrix multiplications,
etc), so I usually end up writing something ugly like this:

column_vector = reshape(A[:,col],(m,1))

I've got a function to wrap this, but is there a builtin (or cleaner)
way to do this sort of operation?

TIA.

Andrew.

```
{"ft_lang_label":"__label__en","ft_lang_prob":0.8495481,"math_prob":0.69769394,"size":610,"snap":"2021-31-2021-39","text_gpt3_token_len":164,"char_repetition_ratio":0.10726073,"word_repetition_ratio":0.0,"special_character_ratio":0.25409836,"punctuation_ratio":0.16541353,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95259345,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-25T19:23:47Z\",\"WARC-Record-ID\":\"<urn:uuid:837ce789-9b96-4a91-8003-ef05e674e7ed>\",\"Content-Length\":\"3517\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b205d6ca-203b-4a81-9fbe-f31b4fd89546>\",\"WARC-Concurrent-To\":\"<urn:uuid:4efe86b6-7398-4b53-9584-d164e7b4fc78>\",\"WARC-IP-Address\":\"188.166.95.178\",\"WARC-Target-URI\":\"https://mail.python.org/pipermail/numpy-discussion/2003-September/002237.html\",\"WARC-Payload-Digest\":\"sha1:PAFECWWACYRXP27KZWBMC2V2JS3FJW6B\",\"WARC-Block-Digest\":\"sha1:R27F6NMF5SQIG43AZPMYWB4FCXASGMBD\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780057733.53_warc_CC-MAIN-20210925172649-20210925202649-00250.warc.gz\"}"}