I am trying to remove the duplicates in a list my_list  In [13]: my_list Out[13]: [[(-7.7725138974675732, -79.168560840024711),   (-7.7725138974675732, -79.168560840024711),   (-5.5, -59.0),   (-4.4, -48.3),   (-3.2, -37.5),   (-2.1, -26.9),   (-0.9, -16.2),   (2.7974572775821454, 4.4251549647685868),   (2.7974572775821454, 4.4251549647685868)],  [(2.7974572775821454, 4.4251549647685868),   (2.7974572775821454, 4.4251549647685868),   (29.8, 16.4),   (41.8, 16.9),   (53.1, 17.2),   (74.767340748230566, 15.947522750252775),   (74.767340748230566, 15.947522750252775),   (74.767340748230566, 15.947522750252775),   (97.8, 13.4),   (109.2, 14.9),   (125.57323627494615, 19.53393479479609)],  [(68.773124224303274, -79.616585806160444),   (68.773124224303274, -79.616585806160444),   (71.141449110088374, -58.675607868692225),   (73.874255065554237, -27.94398092967819),   (73.874255065554237, -27.94398092967819),   (73.874255065554237, -27.94398092967819),   (74.5, -2.9),   (74.767340748230566, 15.947522750252775)],  [(-109.09700131981562, -32.09602243732722),   (-108.3, -32.7),   (-81.9, -52.7),   (-64.94343179027949, -62.943395681375023),   (-64.94343179027949, -62.943395681375023),   (-44.8, -70.5),   (-32.2, -74.1),   (-7.7725138974675732, -79.168560840024711),   (-7.7725138974675732, -79.168560840024711),   (10.6, -80.1),   (21.6, -80.4),   (32.8, -80.6),   (43.9, -80.6),   (68.773124224303274, -79.616585806160444),   (68.773124224303274, -79.616585806160444),   (68.773124224303274, -79.616585806160444),   (94.59403067734813, -75.99089907199837)],  [(-57.743037814594651, 0.48281269760971313),   (-57.743037814594651, 0.48281269760971313),   (-61.5, -30.9),   (-62.9, -42.2),   (-64.94343179027949, -62.943395681375023),   (-64.94343179027949, -62.943395681375023)],  [(73.874255065554237, -27.94398092967819),   (73.874255065554237, -27.94398092967819),   (113.3911596081064, -33.232674908171724)],  [(71.141449110088374, -58.675607868692225),   (71.141449110088374, -58.675607868692225)],  [(2.7974572775821454, 4.4251549647685868),   (-17.6, 3.5),   (-57.743037814594651, 0.48281269760971313),   (-57.743037814594651, 0.48281269760971313)]]   Then, I do my_list = list(set(my_list))  In [20]: my_list Out[20]: [[(-7.7725138974675732, -79.168560840024711),   (-3.2, -37.5),   (-2.1, -26.9),   (-5.5, -59.0),   (-4.4, -48.3),   (-0.9, -16.2),   (2.7974572775821454, 4.4251549647685868)],  [(109.2, 14.9),   (41.8, 16.9),   (97.8, 13.4),   (29.8, 16.4),   (53.1, 17.2),   (125.57323627494615, 19.53393479479609),   (74.767340748230566, 15.947522750252775),   (2.7974572775821454, 4.4251549647685868)],  [(73.874255065554237, -27.94398092967819),   (74.5, -2.9),   (74.767340748230566, 15.947522750252775),   (68.773124224303274, -79.616585806160444),   (71.141449110088374, -58.675607868692225)],  [(-108.3, -32.7),   (-7.7725138974675732, -79.168560840024711),   (-44.8, -70.5),   (-81.9, -52.7),   (10.6, -80.1),   (-64.94343179027949, -62.943395681375023),   (94.59403067734813, -75.99089907199837),   (-109.09700131981562, -32.09602243732722),   (68.773124224303274, -79.616585806160444),   (32.8, -80.6),   (-32.2, -74.1),   (21.6, -80.4),   (43.9, -80.6)],  [(-62.9, -42.2),   (-64.94343179027949, -62.943395681375023),   (-57.743037814594651, 0.48281269760971313),   (-61.5, -30.9)],  [(73.874255065554237, -27.94398092967819),   (113.3911596081064, -33.232674908171724)],  [(71.141449110088374, -58.675607868692225)],  [(-17.6, 3.5),   (-57.743037814594651, 0.48281269760971313),   (2.7974572775821454, 4.4251549647685868)]]   As can be seen, the order of the data has changed. The order is important for me. So I have to maintain the order after the operation.  Why is it so and how do I maintain the order?
8585
Is there a built-in that removes duplicates from list in Python, whilst preserving order? I know that I can use a set to remove duplicates, but that destroys the original order. I also know that I can roll my own like this:  def uniq(input):   output = []   for x in input:     if x not in output:       output.append(x)   return output   (Thanks to  for that .)  But I'd like to avail myself of a built-in or a more Pythonic idiom if possible.  Related question:
49176
Why does python 2.5.2 have the following behavior  &gt;&gt;&gt;[2].extend([]) == [2] False  &gt;&gt;&gt; [2].extend([]) == None True  $ python --version Python 2.5.2   I assume I'm not understanding something here, but intuitively I'd think that [2].extend([]) should yield [2]
110140
Given a list $A$ of $n$ positive integer numbers. We're gonna play this game:  $1 -$ Take randomly $2$ numbers of $A$. $2 -$ Delete this $2$ elements of $A$. $3 -$ Insert in $A$ their gcd and lcm. $4 -$ Go to step $1.$  Prove that after some quantity of steps, $A$ doesn't change its elements.
28240
I have the following data structure (a list of lists)  [  ['4', '21', '1', '14', '2008-10-24 15:42:58'],   ['3', '22', '4', '2somename', '2008-10-24 15:22:03'],   ['5', '21', '3', '19', '2008-10-24 15:45:45'],   ['6', '21', '1', '1somename', '2008-10-24 15:45:49'],   ['7', '22', '3', '2somename', '2008-10-24 15:45:51'] ]   I would like to be able to   Use a function to reorder the list so that I can group by each item in the list. For example I'd like to be able to group by the second column (so that all the 21's are together)  Use a function to only display certain values from each inner list. For example i'd like to reduce this list to only contain the 4th field value of '2somename'    so the list would look like this   [      ['3', '22', '4', '2somename', '2008-10-24 15:22:03'],       ['7', '22', '3', '2somename', '2008-10-24 15:45:51'] ]
94558
\documentclass[12pt]{article}  \usepackage{amsmath,amsthm,amssymb,amsfonts} \usepackage{enumerate}  \newenvironment*{exercise}{}  \newcommand{\R}{\mathbb{R}}  \begin{document}  \begin{exercise}{1.10.} Show that $B=\{[a,b)\subset\R|a&lt;b\}$ is a basis for a topology on $\R$.\\ \begin{enumerate} \item{stuff...} \item{stuff...} \end{enumerate} \end{exercise}  \end{document}   My main concern is that the list numbers in the list and the text in the instructions line up. That is that the S in show is lined up with the 1 and 2 etc in the list.
26817
\begin{multline*} \displaystyle \left \| f  \right \|_{M\dot{K}^{\alpha(\cdot),q}_{p(\cdot), \lambda}(\mathbb{R}^{n})} \approx \max \left\{ \sup_{L\leqslant0,L\in  \mathbb{Z}}2^{-L\lambda}\left ( \sum_{k=-\infty}^{L}2^{k\alpha(0)q}\left \|  f\chi_{k} \right \|^{q}_{L^{p(\cdot)}} \right )^{1/q},\\\sup_{L&gt;0,L\in \mathbb{Z}}\left[ 2^{-L\lambda}\left ( \sum_{k=-\infty}^{-1}2^{k\alpha(0)q} \left \| f\chi_{k} \right \|^{q}_{L^{p(\cdot)}} \right )^{1/q}\\ +2^{-L\lambda}\left ( \sum_{k=0}^{L}2^{k\alpha(\infty)q}\left \|  f\chi_{k} \right \|^{q}_{L^{p(\cdot)}} \right )^{1/q}\right] \right\}  \end{multline*}
10523
I know how to do it normally, but I could swear that you could fill out out like a[0] = {0,0,0,0}; How do you do it that way? I did try Google, but I didn't get anything helpful.
91941
$ cat data.txt  aaaaaa aaaaaa cccccc aaaaaa aaaaaa bbbbbb $ cat data.txt | uniq aaaaaa cccccc aaaaaa bbbbbb $ cat data.txt | sort | uniq aaaaaa bbbbbb cccccc $   The result that I need is to display all the lines from the original file removing all the duplicates (not just the consecutive ones), while maintaining the original order of statements in the file.  Here, in this example, the result that I actually was looking for was  aaaaaa cccccc bbbbbb   How can I perform this generalized uniq operation in general?
19426
If I have a string "1 2 3 2 1" - or an array [1,2,3,2,1] - how can I select the unique values, i.e.  "1 2 3 2 1" produces "1 2 3"    or  [1,2,3,2,1] produces [1,2,3]   Similar to uniq but uniq seems to work on whole lines, not patterns within a line...
9730
How can I remove duplicate values from an array in PHP?
87669
Hope someone can help me. I am using c# and I am somewhat new to it. I am loading a text file into my app and splitting the data on "," I am reading part of string into a &lt;list&gt; when the data is read there is a lot of duplicates that vary depending on the txt file that I load.  Can someone tell me how to check the  and remove any and all duplicates that come up. There is no way of knowing what duplicates will show up as there is infinite possibilities that it could be.  Thanks for the help in advance
96240
Suppose to have a file .dat like this:   -4.8767000e+000 -2.9142000e-001             NaN             NaN             NaN             NaN  -3.9017000e+000 -4.1404000e-001             NaN             NaN             NaN             NaN  -3.7141000e+000             NaN             NaN -2.6865000e-001             NaN             NaN  -2.8267000e+000 -8.5233000e-001             NaN             NaN             NaN             NaN  -2.7641000e+000             NaN -3.0872000e-001             NaN             NaN             NaN  -2.5488000e+000             NaN             NaN -4.1579000e-001             NaN             NaN  -1.9125000e+000             NaN             NaN             NaN             NaN -1.3021000e-001  -1.8869000e+000             NaN             NaN             NaN -2.4675000e-001             NaN  -1.7165000e+000             NaN -5.1881000e-001             NaN             NaN             NaN  -1.6755000e+000 -1.6062000e+000             NaN             NaN             NaN             NaN  -1.4064000e+000             NaN             NaN -6.1630000e-001             NaN             NaN  -8.3837000e-001             NaN             NaN             NaN -5.1510000e-001             NaN  -7.9259000e-001             NaN             NaN             NaN             NaN -4.0836000e-001  -6.4542000e-001 -2.2095000e+000             NaN             NaN             NaN             NaN  -5.4987000e-001             NaN -7.4848000e-001             NaN             NaN             NaN  -4.2297000e-001             NaN             NaN -1.2681000e+000             NaN             NaN   2.0480000e-001             NaN -1.9436000e+000             NaN             NaN             NaN   2.1333000e-001             NaN             NaN             NaN -9.8248000e-001             NaN   3.3584000e-001             NaN             NaN             NaN             NaN -1.2254000e+000   4.4876000e-001 -2.3614000e+000             NaN             NaN             NaN             NaN   7.7282000e-001             NaN             NaN -1.8424000e+000             NaN             NaN   1.3886000e+000             NaN             NaN             NaN -1.7607000e+000             NaN   1.4709000e+000             NaN -2.4598000e+000             NaN             NaN             NaN   1.5644000e+000 -2.3726000e+000             NaN             NaN             NaN             NaN   1.8937000e+000             NaN             NaN -2.1788000e+000             NaN             NaN   2.3417000e+000             NaN             NaN             NaN -1.9949000e+000             NaN   2.4386000e+000             NaN             NaN             NaN             NaN -2.1213000e+000   2.5903000e+000             NaN -2.7040000e+000             NaN             NaN             NaN   2.9174000e+000             NaN             NaN -2.3792000e+000             NaN             NaN   3.4874000e+000             NaN             NaN             NaN -2.4042000e+000             NaN   3.5796000e+000             NaN             NaN             NaN             NaN -2.2296000e+000   3.7549000e+000             NaN -2.8123000e+000             NaN             NaN             NaN   3.9405000e+000             NaN             NaN -2.5407000e+000             NaN             NaN   4.6521000e+000             NaN             NaN             NaN -2.5125000e+000             NaN   If I plot thse data with the following minimal code:  \documentclass{report}  \usepackage[showframe,             margin=2.5cm,             left=3cm]{geometry}  \usepackage{pgfplots} \pgfplotsset{compat=1.4}  \begin{document} \centering \begin{tikzpicture} \begin{axis}  \foreach \n in {1,2,...,5}{ \addplot table[x index = 0,                y index = \n]{DATA.dat}; } \end{axis} \end{tikzpicture} \end{document}   PGFplots skip the first row. It means that the y points in the first row are not plotted!!  Is it because PGFplots see it like a row with column names?  Is it possible to solve this problem?
1477
How can I get the Cartesian product (every possible combination of values) from a group of lists?  Input:   somelists = [    [1, 2, 3],    ['a', 'b'],    [4, 5] ]   Desired output:  [(1, 'a', 4), (1, 'a', 5), (1, 'b', 4), (1, 'b', 5), (2, 'a', 4), (2, 'a', 5) ...]
4618
I have a file containing two columns and 10 million rows. The first column contains many repeated values, but there is a distinct value in column 2. I want to remove the repeated rows and want to keep only one using awk. Note: the file is sorted with values in column 1. For example:    1.123 -4.0 2.234 -3.5 2.234 -3.1 2.234 -2.0 4.432 0.0 5.123 +0.2 8.654 +0.5 8.654 +0.8 8.654 +0.9 . . . .   Expected output  1.123 -4.0 2.234 -3.5 4.432 0.0 5.123 +0.2 8.654 +0.5 . . . .
57998
I know nothing about Excel, so the first thing I would like to do is to remove any duplicates from within the lists themselves.  But then I would also like any rows from list B that has a duplicate row in list A to be removed.  For example, if the email John@John.com is in list B and there is also a John@john.com in list A, I want to remove John@john.com from list B.
3020
How can I remove duplicate values from a multi-dimensional array in PHP?  Example array:  Array (     [0] =&gt; Array     (         [0] =&gt; abc         [1] =&gt; def     )      [1] =&gt; Array     (         [0] =&gt; ghi         [1] =&gt; jkl     )      [2] =&gt; Array     (         [0] =&gt; mno         [1] =&gt; pql     )      [3] =&gt; Array     (         [0] =&gt; abc         [1] =&gt; def     )      [4] =&gt; Array     (         [0] =&gt; ghi         [1] =&gt; jkl     )      [5] =&gt; Array     (         [0] =&gt; mno         [1] =&gt; pql     )  )
27093
I occasionally see the list slice syntax used in Python code like this:  newList = oldList[:]   Surely this is just the same as:  newList = oldList   Or am I missing something?