<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nino Guzman on Medium]]></title>
        <description><![CDATA[Stories by Nino Guzman on Medium]]></description>
        <link>https://medium.com/@ninogdo?source=rss-258fa0cbedf6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OLuFQeLgEjYFwLULBWYAJw.jpeg</url>
            <title>Stories by Nino Guzman on Medium</title>
            <link>https://medium.com/@ninogdo?source=rss-258fa0cbedf6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 15:16:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ninogdo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Cine y datos: Primeros pasos usando web scraping con Python]]></title>
            <link>https://medium.com/tacosdedatos/cine-y-datos-primeros-pasos-usando-web-scraping-con-python-9e82a66203bb?source=rss-258fa0cbedf6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e82a66203bb</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[cine]]></category>
            <category><![CDATA[beautifulsoup]]></category>
            <dc:creator><![CDATA[Nino Guzman]]></dc:creator>
            <pubDate>Thu, 17 Jun 2021 20:01:26 GMT</pubDate>
            <atom:updated>2021-06-18T03:07:02.180Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LkJUTkzvhB47hpHrYst6Zw.png" /></figure><p>Web scraping es una de las técnicas más usadas entre los científicos de datos para recolectar información. En esta breve publicación explicamos con un ejemplo concreto, los primeros pasos para recolectar información desde un blog de WordPress.</p><h3>Antes de empezar…</h3><p>Debemos asegurarnos que podemos hacer <em>scraping </em>en el sitio web. Una forma sencilla de verificarlo es la siguiente:</p><p>Añadimos wp-json/wp/v2/posts al URL del sitio web. En nuestro caso, estaremos analizando el blog de una de las revistas mexicanas con mayor impacto a nivel nacional: <a href="https://www.cinepremiere.com.mx/">Cinepremiere</a>. Entonces, en nuestro navegador tendremos lo siguiente:</p><pre><a href="https://www.cinepremiere.com.mx/wp-json/wp/v2/posts">https://www.cinepremiere.com.mx/wp-json/wp/v2/posts</a></pre><p>Click Enter, debemos observar esto:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b6FEbuvCXvv1Hv5oB3jmMQ.png" /><figcaption>Archivo JSON del sitio web</figcaption></figure><p>Esto es un archivo JSON, lo cual indica que podemos hacer <em>scraping</em> sin problemas.</p><h3>Empezamos…</h3><p>Analizaremos de forma superficial algunas entradas del WordPress de <a href="https://www.cinepremiere.com.mx/">Cinepremiere</a> para dar los primeros pasos usando web scraping.</p><p>Importamos las librerías:</p><pre>import requests<br>from bs4 import BeautifulSoup</pre><p>Definimos lo siguiente y lanzamos el request :</p><pre>url = &#39;<a href="https://www.cinepremiere.com.mx/wp-json/wp/v2/posts&#39;">https://www.cinepremiere.com.mx/wp-json/wp/v2/posts&#39;</a></pre><pre>headers = {<br>        &#39;User-Agent&#39;: &#39;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36&#39;}</pre><pre>r = requests.get(url, headers=headers) # objeto response </pre><pre>file_json = r.json() # archivo JSON</pre><p>El objeto <em>r </em>(response) contiene la siguiente <a href="https://developer.wordpress.org/rest-api/using-the-rest-api/pagination/">información</a> acerca del blog:</p><ul><li><strong>X-WP-Total</strong>: Total de entradas en el sitio web</li><li><strong>X-WP-TotalPages</strong>: Total de número de páginas que contienen todas las entradas</li></ul><pre>print(&#39;Número de entradas: {0}, Número de páginas: {1}&#39;.format(r.headers[&#39;X-WP-Total&#39;], r.headers[&#39;X-WP-TotalPages&#39;]))</pre><p>Salida: Número de entradas: 45407, Número de páginas: 4541</p><p>Observamos los atributos que contiene cada entrada a través de las <em>keys</em> del diccionario:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mikrb4XVKAZd-0zCnyP2mQ.png" /></figure><h3>Extrayendo texto con BeautilfulSoup</h3><p>Estamos interesados en extraer el texto de la entrada, para ello hacemos lo siguiente:</p><pre>contenido_entrada = file_json[0][&#39;content&#39;][&#39;rendered&#39;]<br>contenido_entrada</pre><p>Y nos muestra esto:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fHU0xx0nTQdIjEYCbmjEeA.png" /><figcaption>Contenido original de la entrada</figcaption></figure><p>Usando BeautifulSoup, podemos extraer mayormente el texto de esta entrada:</p><pre>texto_entrada = BeautifulSoup(contenido_entrada).get_text()<br>texto_entrada</pre><p>Y obtenemos algo mucho más limpio (:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BG8mE1X-K-DyI43TWRT1iw.png" /><figcaption>Texto extraído por BeautifulSoup</figcaption></figure><p>Observa que BeautifulSoup no hace el trabajo perfecto, por ejemplo la cadena \n se mantiene en el texto junto con la puntación, por ello es necesario limpiar un poco más para realizar el análisis:</p><pre>import re<br>import string</pre><pre>def limpiar_texto(text):<br>    &#39;&#39;&#39;Convertimos a minúsculas, quitamos braquets y puntuacion&#39;&#39;&#39;<br>    text = text.lower() #<br>    text = re.sub(&#39;\[.*?¿-\]\%&#39;, &#39; &#39;, text)<br>    text = re.sub(&#39;[%s]&#39; % re.escape(string.punctuation), &#39; &#39;, text)<br>    text = re.sub(&#39;\w*\d\w*&#39;, &#39;&#39;, text)<br>    &#39;&#39;&#39;Removemos puntuacion adicional&#39;&#39;&#39;<br>    text = re.sub(&#39;[‘’“”…«»!¡]-&#39;, &#39;&#39;, text)<br>    text = re.sub(&#39;\n&#39;, &#39; &#39;, text)<br>    return text</pre><p>Y lo que obtenemos es el texto (<em>casi</em>) limpio:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1WQWSnQtgEQ166vCOg4Drw.png" /><figcaption>Texto (casi) limpio</figcaption></figure><p>Ahora sí, creamos una nube de palabras usando WordCloud y visualizamos con Matplotlib:</p><pre>from wordcloud import WordCloud<br>from nltk.corpus import stopwords</pre><pre>wc = WordCloud(stopwords=stopwords.words(&#39;spanish&#39;), background_color=&quot;white&quot;, colormap=&quot;Dark2&quot;,<br>               max_font_size=150, random_state=42)</pre><pre>import matplotlib.pyplot as plt<br>plt.rcParams[&#39;figure.figsize&#39;] = [16,12]</pre><pre>wc.generate(texto_limpio)<br>plt.imshow(wc)<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*BId-eu_JHEcmYFvw-fCn2w.png" /><figcaption>Nube de palabras del texto limpio</figcaption></figure><p>Wow, y así en tres patadas realizamos web scraping y una bonita visualización, pero OJO: <strong>¡SOLO ANALIZAMOS UNA ENTRADA!</strong></p><p>Para un análisis más profundo, el primer paso es aprender a extraer más entradas. Así podemos investigar cosas como: tendencias mensuales o anuales, temas más escritos, incluso series, películas o actores más escritos.</p><p>Así que si te gustó y quieres aprender a seguir analizando texto sígueme, porque en las siguientes entradas aprenderemos esto y más.</p><p>Esta entrada esta basada en la <a href="https://samantha-delfin.medium.com/wordpress-blog-scraping-with-beautifulsoup-916a22a46869">publicación</a> de <a href="https://medium.com/u/9cfc0bfd00c0">Samantha Delfin-Azuara</a>, que recomiendo ampliamente leer para mayores detalles.</p><p>También te dejo el código completito en mi <a href="https://github.com/NinoGuzman/Cine_y_Datos">repositorio</a> de Github.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e82a66203bb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tacosdedatos/cine-y-datos-primeros-pasos-usando-web-scraping-con-python-9e82a66203bb">Cine y datos: Primeros pasos usando web scraping con Python</a> was originally published in <a href="https://medium.com/tacosdedatos">tacosdedatos</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Practical exercises to prepare your SQL job test]]></title>
            <link>https://medium.com/geekculture/practical-exercises-to-prepare-your-sql-job-test-fe3c1a03ea05?source=rss-258fa0cbedf6------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe3c1a03ea05</guid>
            <category><![CDATA[sql-queries]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[jobs]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Nino Guzman]]></dc:creator>
            <pubDate>Tue, 08 Jun 2021 23:33:56 GMT</pubDate>
            <atom:updated>2021-06-09T20:05:36.198Z</atom:updated>
            <content:encoded><![CDATA[<p>When you are applying for a data science position, the potential employer wants to know you better, so they will test your programming skills! Many are focusing in Python and R, nevertheless some essential skill is SQL!</p><p>In this short post, I want to share with you an actual real-world set of exercises that (luckily) will help you to prepare your SQL test, or maybe just to be a guide for you to continue your preparation in SQL. So, let’s do this!</p><h3>Preparation</h3><p>Hopefully you will have installed any software to run the SQL queries and make your own experiments, if not, I suggest to create a free account to use Oracle <a href="https://livesql.oracle.com/apex/f?p=590:1000">here</a>, you do not need to install anything!</p><p>The following exercises are a series of a real-world test from a medium size IT consulting company to test their candidates! Even though are basic level, I believe is a perfect start to practice and continue your preparation.</p><p>Remember: an employer wants to test the candidates’ logic, this means, that they do not want the <em>perfect</em> solution, they want to know <em>the way</em> you solve problems.</p><p><strong>What you will practice:</strong></p><ul><li>Basic SELECT + WHERE statements</li><li>JOIN statement</li><li>Scalar and Aggregate functions</li><li>DML (data manipulation language): UPDATE + DELETE</li><li>SET operations</li><li>Finding NULL values</li><li>WITH + SELECT statement</li><li>Subqueries</li></ul><h3>Let’s begin!</h3><p>You have the following schema structure. Do not worry if you do not understand every cell, just keep this in mind:</p><ol><li>There are three tables: cinema, movie and billboard.</li><li>Cinema and movie tables are related to billboard.</li><li>Cinema and movie tables are not directly related to each other.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4fIG1h33Mm8OYKKI26CnlQ.png" /><figcaption>Schema structure</figcaption></figure><p>But the employer did not give any script! Do not worry, I created one so you could practice and make your own experiments: <a href="https://github.com/NinoGuzman/SQLPractice/blob/main/database.sql">https://github.com/NinoGuzman/SQLPractice/blob/main/database.sql</a></p><p>This script creates the following database:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C2Vou5OvTMKbqLYlxaK-HQ.png" /></figure><p><strong>Exercise 1: Show all the distinct age classifications that exists</strong></p><p>Solution:</p><pre>SELECT DISTINCT classification_age <br>FROM movie</pre><p>Logic:</p><p>Probably the first questions are really elemental, in this case just remember that the keyword <em>DISTINCT </em>will avoid displaying doubles.</p><p><strong>Exercise 2: Find cinemas that do not display any movie</strong></p><p>Solution:</p><pre>SELECT cinema_name<br>FROM cinema<br>MINUS<br>SELECT DISTINCT cinema_name<br>FROM cinema <br>NATURAL JOIN billboard <br>NATURAL JOIN movie</pre><p>Logic:</p><ul><li>Using natural join will put the information together for those keys that have coincidences. Analysing <em>billboard </em>table you can observe that the value missing is <strong>id_cinema = 104.</strong></li><li>Then using the <em>minus </em>operation, we substract the common elements from set 1 (all cinemas) and set 2 (cinemas that display movies), that is, the cinemas that do not display movies.</li></ul><p><strong>Exercise 3: Find movies with classification age greater than 16 that are not displayed at any cinema</strong></p><p>Solution:</p><pre>SELECT movie_name<br>FROM movie<br>WHERE id_movie in (<br>    SELECT id_movie <br>    FROM movie<br>    MINUS<br>    SELECT DISTINCT id_movie<br>    FROM billboard<br>    )<br>AND classification_age &gt; 16</pre><p>Logic:</p><ul><li>The subquery in WHERE give us the id_movie from movies that are not displayed at any cinema (similar to the previous exercise).</li><li>Adding the AND keyword filter the classification age.</li></ul><p><strong>Exercise 4: <br>a) Show movies that do not have information about age classification<br>b) Update the information from movies that meet above criteria setting those values to 0 (for all public)</strong></p><p>Solution:</p><pre>a)<br>SELECT movie_name <br>FROM  movie<br>WHERE classification_age IS NULL</pre><pre>b)<br>UPDATE movie<br>SET classification_age = 0<br>WHERE classification_age IS NULL</pre><p><strong>Exercise 5: Delete movies with classification age above 18 that are not display at any cinema</strong></p><p>Solution:</p><pre>DELETE FROM movie <br>WHERE movie_name = (<br>   SELECT movie_name<br>   FROM movie<br>   WHERE id_movie in (<br>       SELECT id_movie <br>       FROM movie<br>       MINUS<br>       SELECT distinct id_movie<br>       FROM billboard<br>       )<br>   AND classification_age &gt; 18     <br>)</pre><p>Logic:</p><ul><li>We use same logic as before to access movies that are not display at any cinema and filter by age (see Exercise 3).</li><li>We use keyword DELETE to remove the results from table <em>movie.</em></li></ul><p><strong>Exercise 6: Count the number of movies available in each cinema</strong></p><p>Solution:</p><pre>SELECT cinema_name, COUNT(DISTINCT id_movie) Total_movies<br>FROM cinema c<br>NATURAL JOIN billboard b<br>NATURAL JOIN movie m<br>GROUP BY cinema_name</pre><p>Logic:</p><ul><li>Remember that we must join all three tables to have the information together, this will give us the movies that are actually display in some cinema.</li><li>Use of scalar and aggregate functions in SQL is also essential, in this case we are counting all the distinct <strong>id_movie </strong>that represent every movie and grouping by cinema.</li></ul><p><strong>Exercise 7: Show the cinemas that display more movies than the number of available screens</strong></p><pre>WITH tab_aux as(<br>    SELECT COUNT(DISTINCT id_movie) Total_movies<br>    FROM cinema c<br>    NATURAL JOIN billboard b<br>    GROUP BY cinema_name</pre><pre>)</pre><pre>SELECT c.cinema_name, c.number_screens, t.Total_movies<br>FROM tab_aux t, cinema c<br>WHERE  c.number_screens &lt; t.Total_movies</pre><p>Logic:</p><ul><li>WITH statement is used to create an auxiliar table that actually contains the same results from above (total movies by cinema)</li><li>Using tables <em>tab_aux </em>and <em>cinema, </em>we filter those cinemas that display more movies than the number of available screens. <br><strong>WARNING: In this case</strong> <strong>all cinemas display less movies than number of avaiblabe screens. So the output will be: <em>no data found.</em></strong></li></ul><p><strong>Exercise 8: Show cinemas that display only movies for all public (classification_age = 0)</strong></p><p>Solution:</p><pre>SELECT id_cinema, cinema_name<br>FROM movie m<br>NATURAL JOIN billboard b<br>NATURAL JOIN cinema c<br>WHERE m.classification_age = 0</pre><p><strong>Exercise 9: Show movies with for public older than 12 that are display in cinemas with number of screens available greater than 5.</strong></p><p>Solution:</p><pre>SELECT movie_name, classification_age, number_screens <br>FROM movie m<br>NATURAL JOIN billboard b<br>NATURAL JOIN cinema c<br>WHERE m.classification_age &gt; 12<br>AND c.number_screens &gt; 5</pre><p>Logic:</p><ul><li>Once the information is put together (natural join) we filter by age and number of screens.</li><li>Remember that notation <em>a.col </em>means: “from table <em>a</em> get column <em>col</em>”</li></ul><p><strong>Exercise 10: Select cinemas, and movies in those cinemas, whose classification age is different from 18.</strong></p><p>Solution:</p><pre>SELECT cinema_name, movie_name, classification_age<br>FROM movie m<br>NATURAL JOIN billboard b<br>NATURAL JOIN cinema c<br>WHERE m.classification_age in (<br>    SELECT DISTINCT classification_age<br>    FROM movie<br>    WHERE classification_age != 18<br>)</pre><p>Logic:</p><ul><li>Subquery is used to get all classification ages distinct from 18.</li><li>When information is put together we select cinemas, movies and classification age except classification age = 18.</li></ul><h3>Final Comments</h3><p>I hope the above exercises are useful to practice your SQL skills. I encourage you to download the code and run the queries and make your own experiments, that how we really learn!</p><p>If you found this interesting, please follow me. And do not hesitate to contact me if you have comments, questions or suggestions.</p><p>Let me know if you are interested in a similar post showing how to create the database from the example, or more complex SQL exercises.</p><p>Good luck!</p><p>Github repository: <a href="https://github.com/NinoGuzman/SQLPractice.git">https://github.com/NinoGuzman/SQLPractice.git</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe3c1a03ea05" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/practical-exercises-to-prepare-your-sql-job-test-fe3c1a03ea05">Practical exercises to prepare your SQL job test</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>