diff --git a/2/Labo2.ipynb b/2/Labo2.ipynb index 7dba856..c9d007f 100644 --- a/2/Labo2.ipynb +++ b/2/Labo2.ipynb @@ -121,9 +121,10 @@ "\n", "def datify(s):\n", " s = s.replace('\\n','').split('/')\n", - "\n", - " return datetime.date(int(s[2]), int(s[0]), int(s[1]))\n", - "\n", + " y,m,d = s[2], s[0], s[1]\n", + " if len(y) < 4:\n", + " y = y+\"0\"\n", + " return datetime.date(int(y), int(m), int(d))\n", "\n", "def parser(lines):\n", " sol = []\n", @@ -164,21 +165,21 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[('Al Pacino', datetime.date(1940, 4, 25)), ('Albert Einstein', datetime.date(1879, 3, 14)), ('Alfred Nobel', datetime.date(1833, 10, 21)), ('Alice Cooper', datetime.date(1948, 2, 4)), ('Aretha Franklin', datetime.date(1942, 3, 25)), ('Axl Rose', datetime.date(1962, 2, 6)), ('Ben Affleck', datetime.date(1972, 8, 15)), ('Benjamin Franklin', datetime.date(1706, 1, 17)), ('Bette Davies', datetime.date(1908, 4, 5)), ('Betty White', datetime.date(1922, 1, 17)), ('Bob Dylan', datetime.date(1941, 5, 24)), ('Bob Geldof', datetime.date(1954, 10, 5)), ('Bobby Fisher', datetime.date(1943, 3, 9)), ('Brandon Lee', datetime.date(1965, 2, 1)), ('Bridget Fonda', datetime.date(1964, 1, 27)), ('Bruce Springsteen', datetime.date(1949, 9, 23)), ('Charles Dickens', datetime.date(1812, 2, 7)), ('Charles Lindbergh', datetime.date(1902, 2, 4)), ('Cliff Richard', datetime.date(1940, 10, 14)), ('Condoleezza Rice', datetime.date(1954, 11, 14)), ('Dalai Lama', datetime.date(1935, 6, 6)), ('Demi Moore', datetime.date(1962, 11, 11)), ('Dolph Lungren', datetime.date(1959, 11, 3)), ('Dr Benjamin Spock', datetime.date(1903, 5, 2)), ('Elisabeth Taylor', datetime.date(1932, 2, 27)), ('Freddy Mercury', datetime.date(1946, 9, 5)), ('George Lukas', datetime.date(1944, 5, 14)), ('Hugh Grant', datetime.date(1960, 9, 9)), ('Iggy Pop', datetime.date(1947, 4, 21)), ('Isaac Newton', datetime.date(1642, 12, 25)), ('J. Edgar Hoover', datetime.date(1895, 1, 1)), ('James Brown', datetime.date(1933, 5, 3)), ('Jennifer Anniston', datetime.date(1969, 2, 11)), ('John F. Kennedy', datetime.date(1917, 5, 29)), ('John Ford', datetime.date(1895, 2, 1)), ('Johnny Cash', datetime.date(1932, 2, 26)), ('Julie Andrews', datetime.date(1935, 10, 1)), ('Karl Marx', datetime.date(1818, 5, 5)), ('Kate Moss', datetime.date(197, 1, 16)), ('Kate Winslet', datetime.date(1975, 10, 5)), ('Leonard Cohen', datetime.date(1934, 9, 21)), ('Leonardo di Caprio', datetime.date(1974, 11, 11)), ('Louis Armstrong', datetime.date(1901, 8, 4)), ('Madeleine Albright', datetime.date(1937, 5, 15)), ('Marlon Brando', datetime.date(1924, 4, 3)), ('Mel Gibson', datetime.date(1956, 1, 3)), ('Michael Schumacher', datetime.date(1969, 1, 3)), ('Moeder Teresa', datetime.date(1910, 8, 27)), ('Mohammed Ali', datetime.date(1942, 1, 17)), ('Naomi Campbell', datetime.date(1970, 5, 22)), ('Nina Simone', datetime.date(1933, 2, 21)), ('O.J. Simpson', datetime.date(1947, 6, 9)), ('Oliver Stone', datetime.date(1946, 9, 15)), ('Orlando Bloom', datetime.date(1977, 1, 13)), ('Osama Bin Laden', datetime.date(1957, 3, 10)), ('Oscar Wilde', datetime.date(1854, 10, 16)), ('Patrick Swayze', datetime.date(1952, 8, 18)), ('Phill Collins', datetime.date(1951, 1, 30)), ('Prins Harry', datetime.date(1984, 9, 15)), ('Prins charles', datetime.date(1948, 11, 14)), ('Prinses Diana', datetime.date(1961, 6, 1)), ('Richard Nixon', datetime.date(1913, 1, 9)), ('Robert Wagner', datetime.date(1930, 2, 10)), ('Roman Polanski', datetime.date(1933, 8, 18)), ('Ronald Reagon', datetime.date(1911, 2, 6)), ('Russel Crowe', datetime.date(1964, 4, 7)), ('Sigmund Freud', datetime.date(1856, 5, 6)), ('Stephen King', datetime.date(1947, 9, 21)), ('Steve Martin', datetime.date(1945, 8, 14)), ('Steven Jobs', datetime.date(1955, 2, 24)), ('Tara Reid', datetime.date(1975, 11, 8)), ('Tom Cruise', datetime.date(1962, 6, 3)), ('Tori Amos', datetime.date(1963, 8, 22)), ('William Clark', datetime.date(1770, 8, 1)), ('Yves Saint Laurent', datetime.date(1936, 8, 1))]\n" + "197\n", + "[('Al Pacino', datetime.date(1940, 4, 25)), ('Albert Einstein', datetime.date(1879, 3, 14)), ('Alfred Nobel', datetime.date(1833, 10, 21)), ('Alice Cooper', datetime.date(1948, 2, 4)), ('Aretha Franklin', datetime.date(1942, 3, 25)), ('Axl Rose', datetime.date(1962, 2, 6)), ('Ben Affleck', datetime.date(1972, 8, 15)), ('Benjamin Franklin', datetime.date(1706, 1, 17)), ('Bette Davies', datetime.date(1908, 4, 5)), ('Betty White', datetime.date(1922, 1, 17)), ('Bob Dylan', datetime.date(1941, 5, 24)), ('Bob Geldof', datetime.date(1954, 10, 5)), ('Bobby Fisher', datetime.date(1943, 3, 9)), ('Brandon Lee', datetime.date(1965, 2, 1)), ('Bridget Fonda', datetime.date(1964, 1, 27)), ('Bruce Springsteen', datetime.date(1949, 9, 23)), ('Charles Dickens', datetime.date(1812, 2, 7)), ('Charles Lindbergh', datetime.date(1902, 2, 4)), ('Cliff Richard', datetime.date(1940, 10, 14)), ('Condoleezza Rice', datetime.date(1954, 11, 14)), ('Dalai Lama', datetime.date(1935, 6, 6)), ('Demi Moore', datetime.date(1962, 11, 11)), ('Dolph Lungren', datetime.date(1959, 11, 3)), ('Dr Benjamin Spock', datetime.date(1903, 5, 2)), ('Elisabeth Taylor', datetime.date(1932, 2, 27)), ('Freddy Mercury', datetime.date(1946, 9, 5)), ('George Lukas', datetime.date(1944, 5, 14)), ('Hugh Grant', datetime.date(1960, 9, 9)), ('Iggy Pop', datetime.date(1947, 4, 21)), ('Isaac Newton', datetime.date(1642, 12, 25)), ('J. Edgar Hoover', datetime.date(1895, 1, 1)), ('James Brown', datetime.date(1933, 5, 3)), ('Jennifer Anniston', datetime.date(1969, 2, 11)), ('John F. Kennedy', datetime.date(1917, 5, 29)), ('John Ford', datetime.date(1895, 2, 1)), ('Johnny Cash', datetime.date(1932, 2, 26)), ('Julie Andrews', datetime.date(1935, 10, 1)), ('Karl Marx', datetime.date(1818, 5, 5)), ('Kate Moss', datetime.date(1970, 1, 16)), ('Kate Winslet', datetime.date(1975, 10, 5)), ('Leonard Cohen', datetime.date(1934, 9, 21)), ('Leonardo di Caprio', datetime.date(1974, 11, 11)), ('Louis Armstrong', datetime.date(1901, 8, 4)), ('Madeleine Albright', datetime.date(1937, 5, 15)), ('Marlon Brando', datetime.date(1924, 4, 3)), ('Mel Gibson', datetime.date(1956, 1, 3)), ('Michael Schumacher', datetime.date(1969, 1, 3)), ('Moeder Teresa', datetime.date(1910, 8, 27)), ('Mohammed Ali', datetime.date(1942, 1, 17)), ('Naomi Campbell', datetime.date(1970, 5, 22)), ('Nina Simone', datetime.date(1933, 2, 21)), ('O.J. Simpson', datetime.date(1947, 6, 9)), ('Oliver Stone', datetime.date(1946, 9, 15)), ('Orlando Bloom', datetime.date(1977, 1, 13)), ('Osama Bin Laden', datetime.date(1957, 3, 10)), ('Oscar Wilde', datetime.date(1854, 10, 16)), ('Patrick Swayze', datetime.date(1952, 8, 18)), ('Phill Collins', datetime.date(1951, 1, 30)), ('Prins Harry', datetime.date(1984, 9, 15)), ('Prins charles', datetime.date(1948, 11, 14)), ('Prinses Diana', datetime.date(1961, 6, 1)), ('Richard Nixon', datetime.date(1913, 1, 9)), ('Robert Wagner', datetime.date(1930, 2, 10)), ('Roman Polanski', datetime.date(1933, 8, 18)), ('Ronald Reagon', datetime.date(1911, 2, 6)), ('Russel Crowe', datetime.date(1964, 4, 7)), ('Sigmund Freud', datetime.date(1856, 5, 6)), ('Stephen King', datetime.date(1947, 9, 21)), ('Steve Martin', datetime.date(1945, 8, 14)), ('Steven Jobs', datetime.date(1955, 2, 24)), ('Tara Reid', datetime.date(1975, 11, 8)), ('Tom Cruise', datetime.date(1962, 6, 3)), ('Tori Amos', datetime.date(1963, 8, 22)), ('William Clark', datetime.date(1770, 8, 1)), ('Yves Saint Laurent', datetime.date(1936, 8, 1))]\n" ] }, { "data": { "text/plain": [ - "[('Kate Moss', datetime.date(197, 1, 16)),\n", - " ('Isaac Newton', datetime.date(1642, 12, 25)),\n", + "[('Isaac Newton', datetime.date(1642, 12, 25)),\n", " ('Benjamin Franklin', datetime.date(1706, 1, 17)),\n", " ('William Clark', datetime.date(1770, 8, 1)),\n", " ('Charles Dickens', datetime.date(1812, 2, 7)),\n", @@ -245,6 +246,7 @@ " ('Brandon Lee', datetime.date(1965, 2, 1)),\n", " ('Michael Schumacher', datetime.date(1969, 1, 3)),\n", " ('Jennifer Anniston', datetime.date(1969, 2, 11)),\n", + " ('Kate Moss', datetime.date(1970, 1, 16)),\n", " ('Naomi Campbell', datetime.date(1970, 5, 22)),\n", " ('Ben Affleck', datetime.date(1972, 8, 15)),\n", " ('Leonardo di Caprio', datetime.date(1974, 11, 11)),\n", @@ -254,7 +256,7 @@ " ('Prins Harry', datetime.date(1984, 9, 15))]" ] }, - "execution_count": 23, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -268,8 +270,10 @@ "\n", "def datify(s):\n", " s = s.replace('\\n','').split('/')\n", - "\n", - " return datetime.date(int(s[2]), int(s[0]), int(s[1]))\n", + " y,m,d = s[2], s[0], s[1]\n", + " if len(y) < 4:\n", + " y = y+\"0\"\n", + " return datetime.date(int(y), int(m), int(d))\n", "\n", "\n", "def parser(lines):\n", @@ -340,22 +344,21 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 58, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[('Albert Einstein', datetime.date(1879, 3, 14)), ('Benjamin Franklin', datetime.date(1706, 1, 17)), ('J. Edgar Hoover', datetime.date(1895, 1, 1)), ('Mel Gibson', datetime.date(1956, 1, 3)), ('Michael Schumacher', datetime.date(1969, 1, 3)), ('Richard Nixon', datetime.date(1913, 1, 9)), ('Orlando Bloom', datetime.date(1977, 1, 13)), ('Kate Moss', datetime.date(197, 1, 16)), ('Betty White', datetime.date(1922, 1, 17)), ('Mohammed Ali', datetime.date(1942, 1, 17)), ('Bridget Fonda', datetime.date(1964, 1, 27)), ('Phill Collins', datetime.date(1951, 1, 30)), ('John Ford', datetime.date(1895, 2, 1)), ('Brandon Lee', datetime.date(1965, 2, 1)), ('Charles Lindbergh', datetime.date(1902, 2, 4)), ('Alice Cooper', datetime.date(1948, 2, 4)), ('Ronald Reagon', datetime.date(1911, 2, 6)), ('Axl Rose', datetime.date(1962, 2, 6)), ('Charles Dickens', datetime.date(1812, 2, 7)), ('Robert Wagner', datetime.date(1930, 2, 10)), ('Jennifer Anniston', datetime.date(1969, 2, 11)), ('Nina Simone', datetime.date(1933, 2, 21)), ('Steven Jobs', datetime.date(1955, 2, 24)), ('Johnny Cash', datetime.date(1932, 2, 26)), ('Elisabeth Taylor', datetime.date(1932, 2, 27)), ('Bobby Fisher', datetime.date(1943, 3, 9)), ('Osama Bin Laden', datetime.date(1957, 3, 10)), ('Aretha Franklin', datetime.date(1942, 3, 25)), ('Marlon Brando', datetime.date(1924, 4, 3)), ('Bette Davies', datetime.date(1908, 4, 5)), ('Russel Crowe', datetime.date(1964, 4, 7)), ('Iggy Pop', datetime.date(1947, 4, 21)), ('Al Pacino', datetime.date(1940, 4, 25)), ('James Brown', datetime.date(1933, 5, 3)), ('Dr Benjamin Spock', datetime.date(1903, 5, 2)), ('Karl Marx', datetime.date(1818, 5, 5)), ('Sigmund Freud', datetime.date(1856, 5, 6)), ('George Lukas', datetime.date(1944, 5, 14)), ('Madeleine Albright', datetime.date(1937, 5, 15)), ('Naomi Campbell', datetime.date(1970, 5, 22)), ('Bob Dylan', datetime.date(1941, 5, 24)), ('John F. Kennedy', datetime.date(1917, 5, 29)), ('Prinses Diana', datetime.date(1961, 6, 1)), ('Tom Cruise', datetime.date(1962, 6, 3)), ('Dalai Lama', datetime.date(1935, 6, 6)), ('O.J. Simpson', datetime.date(1947, 6, 9)), ('William Clark', datetime.date(1770, 8, 1)), ('Yves Saint Laurent', datetime.date(1936, 8, 1)), ('Louis Armstrong', datetime.date(1901, 8, 4)), ('Steve Martin', datetime.date(1945, 8, 14)), ('Ben Affleck', datetime.date(1972, 8, 15)), ('Patrick Swayze', datetime.date(1952, 8, 18)), ('Roman Polanski', datetime.date(1933, 8, 18)), ('Tori Amos', datetime.date(1963, 8, 22)), ('Moeder Teresa', datetime.date(1910, 8, 27)), ('Freddy Mercury', datetime.date(1946, 9, 5)), ('Hugh Grant', datetime.date(1960, 9, 9)), ('Prins Harry', datetime.date(1984, 9, 15)), ('Oliver Stone', datetime.date(1946, 9, 15)), ('Leonard Cohen', datetime.date(1934, 9, 21)), ('Stephen King', datetime.date(1947, 9, 21)), ('Bruce Springsteen', datetime.date(1949, 9, 23)), ('Julie Andrews', datetime.date(1935, 10, 1)), ('Bob Geldof', datetime.date(1954, 10, 5)), ('Kate Winslet', datetime.date(1975, 10, 5)), ('Cliff Richard', datetime.date(1940, 10, 14)), ('Oscar Wilde', datetime.date(1854, 10, 16)), ('Alfred Nobel', datetime.date(1833, 10, 21)), ('Dolph Lungren', datetime.date(1959, 11, 3)), ('Tara Reid', datetime.date(1975, 11, 8)), ('Demi Moore', datetime.date(1962, 11, 11)), ('Leonardo di Caprio', datetime.date(1974, 11, 11)), ('Condoleezza Rice', datetime.date(1954, 11, 14)), ('Prins charles', datetime.date(1948, 11, 14)), ('Isaac Newton', datetime.date(1642, 12, 25)), ('Roger Federer', datetime.date(1981, 8, 8)), ('Dustin Hoffman', datetime.date(1937, 8, 8)), ('Vanessa Amorosi', datetime.date(1981, 8, 8)), ('Whitney Houston', datetime.date(1963, 8, 9)), ('Meat Loaf', datetime.date(1947, 9, 27)), ('Cheryl Tiegs', datetime.date(1947, 9, 27)), ('Robert Redford', datetime.date(1936, 8, 18))]\n", - "[('Al Pacino', datetime.date(1940, 4, 25)), ('Albert Einstein', datetime.date(1879, 3, 14)), ('Alfred Nobel', datetime.date(1833, 10, 21)), ('Alice Cooper', datetime.date(1948, 2, 4)), ('Aretha Franklin', datetime.date(1942, 3, 25)), ('Axl Rose', datetime.date(1962, 2, 6)), ('Ben Affleck', datetime.date(1972, 8, 15)), ('Benjamin Franklin', datetime.date(1706, 1, 17)), ('Bette Davies', datetime.date(1908, 4, 5)), ('Betty White', datetime.date(1922, 1, 17)), ('Bob Dylan', datetime.date(1941, 5, 24)), ('Bob Geldof', datetime.date(1954, 10, 5)), ('Bobby Fisher', datetime.date(1943, 3, 9)), ('Brandon Lee', datetime.date(1965, 2, 1)), ('Bridget Fonda', datetime.date(1964, 1, 27)), ('Bruce Springsteen', datetime.date(1949, 9, 23)), ('Charles Dickens', datetime.date(1812, 2, 7)), ('Charles Lindbergh', datetime.date(1902, 2, 4)), ('Cheryl Tiegs', datetime.date(1947, 9, 27)), ('Cliff Richard', datetime.date(1940, 10, 14)), ('Condoleezza Rice', datetime.date(1954, 11, 14)), ('Dalai Lama', datetime.date(1935, 6, 6)), ('Demi Moore', datetime.date(1962, 11, 11)), ('Dolph Lungren', datetime.date(1959, 11, 3)), ('Dr Benjamin Spock', datetime.date(1903, 5, 2)), ('Dustin Hoffman', datetime.date(1937, 8, 8)), ('Elisabeth Taylor', datetime.date(1932, 2, 27)), ('Freddy Mercury', datetime.date(1946, 9, 5)), ('George Lukas', datetime.date(1944, 5, 14)), ('Hugh Grant', datetime.date(1960, 9, 9)), ('Iggy Pop', datetime.date(1947, 4, 21)), ('Isaac Newton', datetime.date(1642, 12, 25)), ('J. Edgar Hoover', datetime.date(1895, 1, 1)), ('James Brown', datetime.date(1933, 5, 3)), ('Jennifer Anniston', datetime.date(1969, 2, 11)), ('John F. Kennedy', datetime.date(1917, 5, 29)), ('John Ford', datetime.date(1895, 2, 1)), ('Johnny Cash', datetime.date(1932, 2, 26)), ('Julie Andrews', datetime.date(1935, 10, 1)), ('Karl Marx', datetime.date(1818, 5, 5)), ('Kate Moss', datetime.date(197, 1, 16)), ('Kate Winslet', datetime.date(1975, 10, 5)), ('Leonard Cohen', datetime.date(1934, 9, 21)), ('Leonardo di Caprio', datetime.date(1974, 11, 11)), ('Louis Armstrong', datetime.date(1901, 8, 4)), ('Madeleine Albright', datetime.date(1937, 5, 15)), ('Marlon Brando', datetime.date(1924, 4, 3)), ('Meat Loaf', datetime.date(1947, 9, 27)), ('Mel Gibson', datetime.date(1956, 1, 3)), ('Michael Schumacher', datetime.date(1969, 1, 3)), ('Moeder Teresa', datetime.date(1910, 8, 27)), ('Mohammed Ali', datetime.date(1942, 1, 17)), ('Naomi Campbell', datetime.date(1970, 5, 22)), ('Nina Simone', datetime.date(1933, 2, 21)), ('O.J. Simpson', datetime.date(1947, 6, 9)), ('Oliver Stone', datetime.date(1946, 9, 15)), ('Orlando Bloom', datetime.date(1977, 1, 13)), ('Osama Bin Laden', datetime.date(1957, 3, 10)), ('Oscar Wilde', datetime.date(1854, 10, 16)), ('Patrick Swayze', datetime.date(1952, 8, 18)), ('Phill Collins', datetime.date(1951, 1, 30)), ('Prins Harry', datetime.date(1984, 9, 15)), ('Prins charles', datetime.date(1948, 11, 14)), ('Prinses Diana', datetime.date(1961, 6, 1)), ('Richard Nixon', datetime.date(1913, 1, 9)), ('Robert Redford', datetime.date(1936, 8, 18)), ('Robert Wagner', datetime.date(1930, 2, 10)), ('Roger Federer', datetime.date(1981, 8, 8)), ('Roman Polanski', datetime.date(1933, 8, 18)), ('Ronald Reagon', datetime.date(1911, 2, 6)), ('Russel Crowe', datetime.date(1964, 4, 7)), ('Sigmund Freud', datetime.date(1856, 5, 6)), ('Stephen King', datetime.date(1947, 9, 21)), ('Steve Martin', datetime.date(1945, 8, 14)), ('Steven Jobs', datetime.date(1955, 2, 24)), ('Tara Reid', datetime.date(1975, 11, 8)), ('Tom Cruise', datetime.date(1962, 6, 3)), ('Tori Amos', datetime.date(1963, 8, 22)), ('Vanessa Amorosi', datetime.date(1981, 8, 8)), ('Whitney Houston', datetime.date(1963, 8, 9)), ('William Clark', datetime.date(1770, 8, 1)), ('Yves Saint Laurent', datetime.date(1936, 8, 1))]\n" + "[('Albert Einstein', datetime.date(1879, 3, 14)), ('Benjamin Franklin', datetime.date(1706, 1, 17)), ('J. Edgar Hoover', datetime.date(1895, 1, 1)), ('Mel Gibson', datetime.date(1956, 1, 3)), ('Michael Schumacher', datetime.date(1969, 1, 3)), ('Richard Nixon', datetime.date(1913, 1, 9)), ('Orlando Bloom', datetime.date(1977, 1, 13)), ('Kate Moss', datetime.date(1970, 1, 16)), ('Betty White', datetime.date(1922, 1, 17)), ('Mohammed Ali', datetime.date(1942, 1, 17)), ('Bridget Fonda', datetime.date(1964, 1, 27)), ('Phill Collins', datetime.date(1951, 1, 30)), ('John Ford', datetime.date(1895, 2, 1)), ('Brandon Lee', datetime.date(1965, 2, 1)), ('Charles Lindbergh', datetime.date(1902, 2, 4)), ('Alice Cooper', datetime.date(1948, 2, 4)), ('Ronald Reagon', datetime.date(1911, 2, 6)), ('Axl Rose', datetime.date(1962, 2, 6)), ('Charles Dickens', datetime.date(1812, 2, 7)), ('Robert Wagner', datetime.date(1930, 2, 10)), ('Jennifer Anniston', datetime.date(1969, 2, 11)), ('Nina Simone', datetime.date(1933, 2, 21)), ('Steven Jobs', datetime.date(1955, 2, 24)), ('Johnny Cash', datetime.date(1932, 2, 26)), ('Elisabeth Taylor', datetime.date(1932, 2, 27)), ('Bobby Fisher', datetime.date(1943, 3, 9)), ('Osama Bin Laden', datetime.date(1957, 3, 10)), ('Aretha Franklin', datetime.date(1942, 3, 25)), ('Marlon Brando', datetime.date(1924, 4, 3)), ('Bette Davies', datetime.date(1908, 4, 5)), ('Russel Crowe', datetime.date(1964, 4, 7)), ('Iggy Pop', datetime.date(1947, 4, 21)), ('Al Pacino', datetime.date(1940, 4, 25)), ('James Brown', datetime.date(1933, 5, 3)), ('Dr Benjamin Spock', datetime.date(1903, 5, 2)), ('Karl Marx', datetime.date(1818, 5, 5)), ('Sigmund Freud', datetime.date(1856, 5, 6)), ('George Lukas', datetime.date(1944, 5, 14)), ('Madeleine Albright', datetime.date(1937, 5, 15)), ('Naomi Campbell', datetime.date(1970, 5, 22)), ('Bob Dylan', datetime.date(1941, 5, 24)), ('John F. Kennedy', datetime.date(1917, 5, 29)), ('Prinses Diana', datetime.date(1961, 6, 1)), ('Tom Cruise', datetime.date(1962, 6, 3)), ('Dalai Lama', datetime.date(1935, 6, 6)), ('O.J. Simpson', datetime.date(1947, 6, 9)), ('William Clark', datetime.date(1770, 8, 1)), ('Yves Saint Laurent', datetime.date(1936, 8, 1)), ('Louis Armstrong', datetime.date(1901, 8, 4)), ('Steve Martin', datetime.date(1945, 8, 14)), ('Ben Affleck', datetime.date(1972, 8, 15)), ('Patrick Swayze', datetime.date(1952, 8, 18)), ('Roman Polanski', datetime.date(1933, 8, 18)), ('Tori Amos', datetime.date(1963, 8, 22)), ('Moeder Teresa', datetime.date(1910, 8, 27)), ('Freddy Mercury', datetime.date(1946, 9, 5)), ('Hugh Grant', datetime.date(1960, 9, 9)), ('Prins Harry', datetime.date(1984, 9, 15)), ('Oliver Stone', datetime.date(1946, 9, 15)), ('Leonard Cohen', datetime.date(1934, 9, 21)), ('Stephen King', datetime.date(1947, 9, 21)), ('Bruce Springsteen', datetime.date(1949, 9, 23)), ('Julie Andrews', datetime.date(1935, 10, 1)), ('Bob Geldof', datetime.date(1954, 10, 5)), ('Kate Winslet', datetime.date(1975, 10, 5)), ('Cliff Richard', datetime.date(1940, 10, 14)), ('Oscar Wilde', datetime.date(1854, 10, 16)), ('Alfred Nobel', datetime.date(1833, 10, 21)), ('Dolph Lungren', datetime.date(1959, 11, 3)), ('Tara Reid', datetime.date(1975, 11, 8)), ('Demi Moore', datetime.date(1962, 11, 11)), ('Leonardo di Caprio', datetime.date(1974, 11, 11)), ('Condoleezza Rice', datetime.date(1954, 11, 14)), ('Prins charles', datetime.date(1948, 11, 14)), ('Isaac Newton', datetime.date(1642, 12, 25)), ('Roger Federer', datetime.date(1981, 8, 8)), ('Dustin Hoffman', datetime.date(1937, 8, 8)), ('Vanessa Amorosi', datetime.date(1981, 8, 8)), ('Whitney Houston', datetime.date(1963, 8, 9)), ('Meat Loaf', datetime.date(1947, 9, 27)), ('Cheryl Tiegs', datetime.date(1947, 9, 27)), ('Robert Redford', datetime.date(1936, 8, 18))]\n", + "[('Al Pacino', datetime.date(1940, 4, 25)), ('Albert Einstein', datetime.date(1879, 3, 14)), ('Alfred Nobel', datetime.date(1833, 10, 21)), ('Alice Cooper', datetime.date(1948, 2, 4)), ('Aretha Franklin', datetime.date(1942, 3, 25)), ('Axl Rose', datetime.date(1962, 2, 6)), ('Ben Affleck', datetime.date(1972, 8, 15)), ('Benjamin Franklin', datetime.date(1706, 1, 17)), ('Bette Davies', datetime.date(1908, 4, 5)), ('Betty White', datetime.date(1922, 1, 17)), ('Bob Dylan', datetime.date(1941, 5, 24)), ('Bob Geldof', datetime.date(1954, 10, 5)), ('Bobby Fisher', datetime.date(1943, 3, 9)), ('Brandon Lee', datetime.date(1965, 2, 1)), ('Bridget Fonda', datetime.date(1964, 1, 27)), ('Bruce Springsteen', datetime.date(1949, 9, 23)), ('Charles Dickens', datetime.date(1812, 2, 7)), ('Charles Lindbergh', datetime.date(1902, 2, 4)), ('Cheryl Tiegs', datetime.date(1947, 9, 27)), ('Cliff Richard', datetime.date(1940, 10, 14)), ('Condoleezza Rice', datetime.date(1954, 11, 14)), ('Dalai Lama', datetime.date(1935, 6, 6)), ('Demi Moore', datetime.date(1962, 11, 11)), ('Dolph Lungren', datetime.date(1959, 11, 3)), ('Dr Benjamin Spock', datetime.date(1903, 5, 2)), ('Dustin Hoffman', datetime.date(1937, 8, 8)), ('Elisabeth Taylor', datetime.date(1932, 2, 27)), ('Freddy Mercury', datetime.date(1946, 9, 5)), ('George Lukas', datetime.date(1944, 5, 14)), ('Hugh Grant', datetime.date(1960, 9, 9)), ('Iggy Pop', datetime.date(1947, 4, 21)), ('Isaac Newton', datetime.date(1642, 12, 25)), ('J. Edgar Hoover', datetime.date(1895, 1, 1)), ('James Brown', datetime.date(1933, 5, 3)), ('Jennifer Anniston', datetime.date(1969, 2, 11)), ('John F. Kennedy', datetime.date(1917, 5, 29)), ('John Ford', datetime.date(1895, 2, 1)), ('Johnny Cash', datetime.date(1932, 2, 26)), ('Julie Andrews', datetime.date(1935, 10, 1)), ('Karl Marx', datetime.date(1818, 5, 5)), ('Kate Moss', datetime.date(1970, 1, 16)), ('Kate Winslet', datetime.date(1975, 10, 5)), ('Leonard Cohen', datetime.date(1934, 9, 21)), ('Leonardo di Caprio', datetime.date(1974, 11, 11)), ('Louis Armstrong', datetime.date(1901, 8, 4)), ('Madeleine Albright', datetime.date(1937, 5, 15)), ('Marlon Brando', datetime.date(1924, 4, 3)), ('Meat Loaf', datetime.date(1947, 9, 27)), ('Mel Gibson', datetime.date(1956, 1, 3)), ('Michael Schumacher', datetime.date(1969, 1, 3)), ('Moeder Teresa', datetime.date(1910, 8, 27)), ('Mohammed Ali', datetime.date(1942, 1, 17)), ('Naomi Campbell', datetime.date(1970, 5, 22)), ('Nina Simone', datetime.date(1933, 2, 21)), ('O.J. Simpson', datetime.date(1947, 6, 9)), ('Oliver Stone', datetime.date(1946, 9, 15)), ('Orlando Bloom', datetime.date(1977, 1, 13)), ('Osama Bin Laden', datetime.date(1957, 3, 10)), ('Oscar Wilde', datetime.date(1854, 10, 16)), ('Patrick Swayze', datetime.date(1952, 8, 18)), ('Phill Collins', datetime.date(1951, 1, 30)), ('Prins Harry', datetime.date(1984, 9, 15)), ('Prins charles', datetime.date(1948, 11, 14)), ('Prinses Diana', datetime.date(1961, 6, 1)), ('Richard Nixon', datetime.date(1913, 1, 9)), ('Robert Redford', datetime.date(1936, 8, 18)), ('Robert Wagner', datetime.date(1930, 2, 10)), ('Roger Federer', datetime.date(1981, 8, 8)), ('Roman Polanski', datetime.date(1933, 8, 18)), ('Ronald Reagon', datetime.date(1911, 2, 6)), ('Russel Crowe', datetime.date(1964, 4, 7)), ('Sigmund Freud', datetime.date(1856, 5, 6)), ('Stephen King', datetime.date(1947, 9, 21)), ('Steve Martin', datetime.date(1945, 8, 14)), ('Steven Jobs', datetime.date(1955, 2, 24)), ('Tara Reid', datetime.date(1975, 11, 8)), ('Tom Cruise', datetime.date(1962, 6, 3)), ('Tori Amos', datetime.date(1963, 8, 22)), ('Vanessa Amorosi', datetime.date(1981, 8, 8)), ('Whitney Houston', datetime.date(1963, 8, 9)), ('William Clark', datetime.date(1770, 8, 1)), ('Yves Saint Laurent', datetime.date(1936, 8, 1))]\n" ] }, { "data": { "text/plain": [ - "[('Kate Moss', datetime.date(197, 1, 16)),\n", - " ('Isaac Newton', datetime.date(1642, 12, 25)),\n", + "[('Isaac Newton', datetime.date(1642, 12, 25)),\n", " ('Benjamin Franklin', datetime.date(1706, 1, 17)),\n", " ('William Clark', datetime.date(1770, 8, 1)),\n", " ('Charles Dickens', datetime.date(1812, 2, 7)),\n", @@ -427,6 +430,7 @@ " ('Brandon Lee', datetime.date(1965, 2, 1)),\n", " ('Michael Schumacher', datetime.date(1969, 1, 3)),\n", " ('Jennifer Anniston', datetime.date(1969, 2, 11)),\n", + " ('Kate Moss', datetime.date(1970, 1, 16)),\n", " ('Naomi Campbell', datetime.date(1970, 5, 22)),\n", " ('Ben Affleck', datetime.date(1972, 8, 15)),\n", " ('Leonardo di Caprio', datetime.date(1974, 11, 11)),\n", @@ -438,7 +442,7 @@ " ('Prins Harry', datetime.date(1984, 9, 15))]" ] }, - "execution_count": 36, + "execution_count": 58, "metadata": {}, "output_type": "execute_result" } @@ -446,15 +450,15 @@ "source": [ "import datetime\n", "\n", - "with open('DataLabo1_01.txt') as infile:\n", + "with open('Documents/DataLabo1_01.txt') as infile:\n", " lines = infile.readlines()\n", " \n", - "\n", "def datify(s):\n", " s = s.replace('\\n','').split('/')\n", - "\n", - " return datetime.date(int(s[2]), int(s[0]), int(s[1]))\n", - "\n", + " y,m,d = s[2], s[0], s[1]\n", + " if len(y) < 4:\n", + " y = y+\"0\"\n", + " return datetime.date(int(y), int(m), int(d))\n", "\n", "def parser(lines):\n", " sol = []\n", @@ -576,12 +580,9 @@ } ], "source": [ - "\n", "import datetime\n", "\n", "\n", - "\n", - "\n", "def birth_year_month_day(y,m,d,db):\n", " sol = []\n", " if (y,m,d) in gen_same_birthdays(db):\n", @@ -590,8 +591,6 @@ " sol.append(i)\n", " return sol\n", "\n", - "\n", - "#y do dis?\n", "def gen_same_birthdays(db):\n", " temp = [(i[1].year, i[1].month, i[1].day) for i in db]\n", " for i in temp:\n", @@ -611,8 +610,10 @@ "\n", "def datify(s):\n", " s = s.replace('\\n','').split('/')\n", - " return datetime.date(int(s[2]), int(s[0]), int(s[1]))\n", - "\n", + " y,m,d = s[2], s[0], s[1]\n", + " if len(y) < 4:\n", + " y = y+\"0\"\n", + " return datetime.date(int(y), int(m), int(d))\n", "\n", "def parser(lines):\n", " sol = []\n", @@ -665,10 +666,114 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 62, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1, 8, 8, 9, 9, 1]\n", + "[17, 8, 8, 27, 27, 17]\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAD8CAYAAABpcuN4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xt8VPWd//HXNxfABrRaIiggoeiimC0igQ2iEhIrKAjsY2sfUFiCPyuKUnXXblWsqwii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csWqKzksQULGHTjjeTffDPbSksBeOyxxxg0aBD5+fls27YNgD59+jB+/HhmzJjBG2+8wbhx45g1axYVFRWMHDmSIUOGcOuttwLw05/+lNzcXIYMGdLqb/7//A9s2gSvv37yz921axdDhgzh8ssvPxp7Y/70pz+Rl5fHoEGDWLBgQYO/zZkzh7y8PK688krOP/98AObOncsVV1zBFVdc0WD7V69ezauvvkphYSGrV69mzpw55Obmcs899zRrXTfddBOl0ffo6aef5te//nWj+//BBx/khhtuYOjQoRQXFx/97/GOO+5g8ODBXHHFFUff18aW5ebmMnnyZH74wx+yZcsWcnNzGT16NDt27AAiH+rBgweTm5vLzJkzAdi7dy9Dhgzh2muvZdSoURQVFWFmTJ48mfz8fIYPH86+ffsoKipi1KhRXHfddQwaNIiqk+jJnqxnnnmG3bt3A5Ge1ezZs0/q+YnWPlp0LKDxz31LjwXNbT9z5sxh1qxZjBs3joULFzJ37lwg0paLioooKipi9OjRjBo1issvv5zFixdTUFDA8OHDMTPefvtt/uEf/oH8/Hzmz5/fzHe4GczshD/vvfdemZkVx/xZvrzU2rattZQUs7Zta2358tImn3PcT2Vl5XsbNmz44rPPPtt8zTXX1G7YsGHjf//3f79/22237d6wYcOBSy+9tNLMigcNGvT53r1719XW1hYPHDjwi4MHD641s+K//OUvtnTpUnvkkUfMzOyWW26xBQsW2IYNG2zSpElmZrZp0yabNGmSbdmyxS688EKrrq62d955x26++WYr/+gjuzo31+zdd23V3Ll2y403Wnl5uV199dVmZrZq1Sq75ZZbzMzsrLPOsqqqKjMzKywstA8//NDMzP71X//V3n77bTMz+9GPfmRvv/22ffvb37YDBw6YmVldXZ21hrFjzTIyzNLSzCBym5ERWd5chw8fturqajMzGzdunH3wwQe2cuVKu++++8zMbNCgQWZmdvXVV9vnn39udXV1VlBQYIcPH/7Ka91zzz32y1/+0ioqKuy6666zuro627t3r40aNarBa9Xvu+rqahswYIBVV1fbH//4Rxs8eHCT63rjjTfsoYceMjOza665xqqqqhrd/w888IDNnDnTzMy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mtlPgo7HS2Z2r5l1NbMsIidEf29mofjv1Mw+AbY753pFFxUAmwIMySvbgFzn3NeibbOAEJykP86rQGH090LglQBj8ZRzbhhwNzDSzA601nqUKPw3CPhnIv9tvxf9uTbooKRZfgAsds5tAC4BZgYcT4tFe0gvAeuAjUSOCQn7LWbn3BJgDdDLObfDOXcj8Cjwbefch8C3o/cTzgm2bTbQAVgePZb8rFXWrW9mi4hILOpRiIhITEoUIiISkxKFiIjEpEQhIiIxKVGIiEhMShQiIhKTEoWIiMSkRCEiIjH9f7auZFoRDx4CAAAAAElFTkSuQmCC\n", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import datetime\n", + "import matplotlib\n", + "import matplotlib.pyplot as plt\n", + "\n", + "\n", + "def birth_year_month_day(y,m,d,db):\n", + " sol = []\n", + " if (y,m,d) in gen_same_birthdays(db):\n", + " for i in db:\n", + " if i[1] == datetime.date(y,m,d):\n", + " sol.append(i)\n", + " return sol\n", + "\n", + "\n", + "#y do dis?\n", + "def gen_same_birthdays(db):\n", + " temp = [(i[1].year, i[1].month, i[1].day) for i in db]\n", + " for i in temp:\n", + " if temp.count(i) > 1:\n", + " yield i\n", + " \n", + " \n", + "def gen_same_anniversaries(db):\n", + " temp = [(i[1].day, i[1].month) for i in db]\n", + " for i in temp:\n", + " if temp.count(i) > 1:\n", + " yield i\n", + "\n", + "def tmpy(db):\n", + " temp = [(i[1].day,i[1].month) for i in db]\n", + " for i in temp:\n", + " yield i\n", + "\n", + "with open('DataLabo1_01.txt') as infile:\n", + " lines = infile.readlines()\n", + " \n", + "\n", + "def datify(s):\n", + " s = s.replace('\\n','').split('/')\n", + " y,m,d = s[2], s[0], s[1]\n", + " if len(y) < 4:\n", + " y = y+\"0\"\n", + " return datetime.date(int(y), int(m), int(d))\n", + "\n", + "\n", + "def parser(lines):\n", + " sol = []\n", + " for l in lines:\n", + " l= l.split(' ')\n", + " try:\n", + " d = datify(l.pop())\n", + " except ValueError:\n", + " print('euh')\n", + " d = 'NaN'\n", + " name = ' '.join(l)\n", + " sol.append((name,d))\n", + " return sol\n", + "\n", + "f = [('Roger Federer', datetime.date(1981,8,8)),\n", + "('Dustin Hoffman', datetime.date(1937,8,8)),\n", + " ('Vanessa Amorosi', datetime.date(1981,8,8)),\n", + "('Whitney Houston', datetime.date(1963,8,9)),\n", + "('Meat Loaf', datetime.date(1947,9,27)),\n", + "('Cheryl Tiegs', datetime.date(1947,9,27)),\n", + "('Robert Redford',datetime.date(1936,8,18)),\n", + "('David Bowie', datetime.date(1942,1,17))]\n", + "\n", + "sol = parser(lines)\n", + "sol.extend(f)\n", + "temp = gen_same_birthdays(sol)\n", + "temp = gen_same_anniversaries(sol)\n", + "temp = birth_year_month_day(1942,1,17,sol)\n", + "print([i[1] for i in gen_same_birthdays(sol)])\n", + "print([i[2] for i in gen_same_birthdays(sol)])\n", + "a = plt.scatter([i[1] for i in tmpy(sol)],[i[0] for i in tmpy(sol)],marker='.', c='r')\n", + "b = plt.scatter([i[1] for i in gen_same_anniversaries(sol)],[i[0] for i in gen_same_anniversaries(sol)],marker='*',c='b')\n", + "c = plt.scatter([i[1] for i in gen_same_birthdays(sol)],[i[2] for i in gen_same_birthdays(sol)],marker='d',c='black')\n", + "plt.legend((a,b,c),\n", + " ('alle geboortes','alle zelfde verjaardagen', 'alle zelfde geboortedatums'),\n", + " scatterpoints=1,\n", + " ncol=3,\n", + " fontsize=8)\n", + "\n", + "plt.show()" + ] }, { "cell_type": "markdown", @@ -732,9 +837,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[1 2] (2,) int32\n", + "[[2 3]\n", + " [3 5]] (2, 2) int32\n", + "[[ 1 2]\n", + " [ 5 -1]] (2, 2) int32\n", + "[2 4]\n", + "\n", + " [[ 1 4]\n", + " [25 1]]\n", + "[[11 0]\n", + " [ 0 11]]\n", + "[[11 0]\n", + " [ 0 11]]\n", + "\n", + " [[13 21]\n", + " [21 34]]\n", + "[[13 21]\n", + " [21 34]]\n" + ] + } + ], "source": [ "import numpy as np\n", "#vector\n", @@ -748,7 +878,7 @@ "\n", "print(x, x.shape,x.dtype)\n", "print(m, m.shape, m.dtype)\n", - "print(n,n.shape,n.dtype)\n", + "#print(n,n.shape,n.dtype)\n", "print(y, y.shape,y.dtype)\n", "\n", "print(x+x)\n", @@ -778,6 +908,39 @@ "Bereken via matrix operaties in numpy hoeveel euro elk van hen zal betalen." ] }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[100 175 210]\n", + " [ 90 160 150]\n", + " [200 50 100]\n", + " [120 0 310]]\n", + "[[0.039 ]\n", + " [0.0199]\n", + " [0.0298]]\n", + "[[13.6405]\n", + " [11.164 ]\n", + " [11.775 ]\n", + " [13.918 ]]\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "a = np.mat(((100, 175, 210), (90, 160, 150), (200,50,100), (120,0,310)))\n", + "b = np.mat((2.98/100,1.99/100,3.90/100))\n", + "b = np.rot90(b)\n", + "print(a)\n", + "print(b)\n", + "print(a*b)\n" + ] + }, { "cell_type": "code", "execution_count": null, @@ -802,7 +965,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.6.5" } }, "nbformat": 4,