<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Anshaj Khare</title>
    <description>The latest articles on DEV Community by Anshaj Khare (@anshaj).</description>
    <link>https://dev.to/anshaj</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F324810%2F0957571a-a8f2-42fd-8d04-c1963dcd5ce3.png</url>
      <title>DEV Community: Anshaj Khare</title>
      <link>https://dev.to/anshaj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anshaj"/>
    <language>en</language>
    <item>
      <title>Build a GraphQL API in minutes</title>
      <dc:creator>Anshaj Khare</dc:creator>
      <pubDate>Fri, 08 Nov 2024 19:31:37 +0000</pubDate>
      <link>https://dev.to/anshaj/build-a-graphql-api-in-minutes-aj0</link>
      <guid>https://dev.to/anshaj/build-a-graphql-api-in-minutes-aj0</guid>
      <description>&lt;p&gt;Did you know that there are ways today you can build secure, extremely performant APIs today - both REST and GraphQL on top of your existing data in minutes?&lt;/p&gt;

&lt;p&gt;Read to find out how at &lt;a href="https://thecomputeblog.substack.com/p/hasura-effortless-unified-api-on" rel="noopener noreferrer"&gt;https://thecomputeblog.substack.com/p/hasura-effortless-unified-api-on&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>webdev</category>
      <category>graphql</category>
      <category>backenddevelopment</category>
    </item>
    <item>
      <title>How I cleared my AWS Developer associate exam and here's how you can do it too</title>
      <dc:creator>Anshaj Khare</dc:creator>
      <pubDate>Wed, 28 Apr 2021 19:10:47 +0000</pubDate>
      <link>https://dev.to/anshaj/how-i-cleared-my-aws-developer-associate-exam-and-here-s-how-you-can-do-it-too-1fpl</link>
      <guid>https://dev.to/anshaj/how-i-cleared-my-aws-developer-associate-exam-and-here-s-how-you-can-do-it-too-1fpl</guid>
      <description>&lt;p&gt;In the September of 2020, I decided to work towards the AWS developer associate exam. I wanted to use the opportunity to not only learn about AWS more but also to compare it with GCP, which I'd been using for the past 2 years. I ended up scoring 916 out of 1000 when I gave my exam in December of the same year. I created this guide to help those who are wondering whether they should pursue this certification as well as those who are actively preparing for it. &lt;/p&gt;

&lt;p&gt;Why should you take this exam? &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cloud technology is being used everywhere and I'm sure you don't need any convincing on this. AWS is one of the leading cloud platforms and the path towards these certifications involves learning how to use this platform optimally. This, I believe, is the most important reason you should pursue this certification as it'll teach you how to use AWS effectively, and adopt best-practices so that you're better prepared, once you do start working on the platform&lt;/li&gt;
&lt;li&gt;It's a skill that's high in demand. The knowledge that you'll gain during the preparation will make you an important asset of any team that runs it's infrastructure on AWS.&lt;/li&gt;
&lt;li&gt;You'll be able to experiment. For me, the most enjoyable way to learn a technology is to make projects with it. I love developing with code and I find it especially fun to be able to architect my projects in multiple ways. Be it using a serverless architecture instead of traditional auto-scaling instances to using serverless containers and serverless databases. The variations of your architecture are only limited by your imagination (and what is possible with current technology). This also means that you can learn first-hand, the advantages and disadvantages of the various architectures. This knowledge is invaluable and only comes with experience and experimentation. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With the reasons to take this exam out of the way, I'll now focus on how you can prepare for this exam and what you should expect. I'll split up the tips to what will be common for all associate level exams and one that is specific to the developer associate exam. Let's begin.&lt;/p&gt;

&lt;p&gt;What will you need? &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A dedicated course 

&lt;ul&gt;
&lt;li&gt;A dedicated course that walks you over the various things that you need to understand about AWS. There are plenty of courses on various education websites like the ones I've listed below that will help you understand the intricacies in a step by step fashion. Note that these courses are not sponsoring this post in any way and that I'm recommending them based on my own experience. 

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.udemy.com/course/aws-certified-developer-associate-dva-c01/"&gt;Stephen Maarek's course on Udemy&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.udemy.com/course/aws-certified-developer-associate/"&gt;ACloud guru course on Udemy&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;You don't necessarily need a course and can do away with free training from &lt;a href="https://www.aws.training"&gt;AWS training&lt;/a&gt;. You could also learn from both an instructor led course and also from AWS training for more clarity.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;An AWS account

&lt;ul&gt;
&lt;li&gt;Having an AWS account to practice the things that you learn, will significantly increase your understanding of AWS. Concepts like IAM, roles, policy generation, VPC, etc. are best understood when you interact with them on the AWS console (or CLI). I'll strongly advise you to practice creating resources, manage their permissions and terminate them to understand their lifecycle. This will also help when you learn about concepts like &lt;a href="https://aws.amazon.com/cloudformation/"&gt;CloudFormation&lt;/a&gt; or &lt;a href="https://aws.amazon.com/serverless/sam/"&gt;SAM&lt;/a&gt; that allow you to manage infrastructure with code. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Preparation plan

&lt;ul&gt;
&lt;li&gt;I prepared for a month and half before I gave my exam. I had to manage my learning along with my full-time job which was not particularly easy. Motivating yourself to read up more or watch a video after a busy workday is hard. But I'd advise you to persist and learn continuously. If you don't have prior experience with cloud or AWS, you should may end up needing more time for individual concepts to sink in. The services on AWS are abstracted to make it convenient for developers to operate but they also offer a lot of flexibility, which can only be utilised by developers who take the time to study them in detail.&lt;/li&gt;
&lt;li&gt;Make a list of the topics that are relevant for your exam and make sure that you're learning about them on a continuous basis during your preparation. For AWS Developer Associate exam, make sure that you spend enough time on the topics mentioned in the &lt;a href="https://aws.amazon.com/certification/certified-developer-associate/"&gt;exam guide&lt;/a&gt;. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What to expect during the exam?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exam mode - Online/Examination centre: 

&lt;ul&gt;
&lt;li&gt;When I gave my exam, covid-19 restrictions made me choose the online version of the exam, where I could give the exam from the comfort of my home. The exam experience will be different for you considering whether you go for the examination centre vs online exam. I can however, share my experience of the exam, that I took from my home&lt;/li&gt;
&lt;li&gt;The online examination is a proctored exam. This means that at the start of your exam, your proctor will ask you to show your desk and surroundings. Throughout the exam, the proctor monitors you to make sure that you're able to give exam properly and to ensure that there are no malpractice incidents. A stable internet connection and a webcam is a must for online exam. I tried to make sure that everything was in order but I still ended up facing a few problems during my exam 

&lt;ul&gt;
&lt;li&gt;First, the exam application that I had to install on my machine, failed to clear the system checks. This was because of my MacOS (Big-sur() and the application expecting previous versions of macOS. To resolve this, I had to dig out an old windows machine and install the exam software on it. &lt;/li&gt;
&lt;li&gt;Second, in the middle of the test, there was a hiccup in my internet connection. The window of my exam session terminated for a minute, and I panicked. Fortunately, my exam proctor helped me restore the session and I could go back to solving the questions within a minute. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;If you're opting for the online mode of exam, ensure that you have power backup (in case you're not using a laptop) and a very stable internet connection. The policies regarding misconduct are severe and may lead to your exam getting cancelled. You should ensure that your room is quiet as well, to avoid any potential issues with your exam.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Be prepared for scenario based questions. Though some questions will be fact based, answering which will depend on your memory, a lot of questions will be scenario based and the choices may be confusing. Hence, while going through your preparation, make sure that you study the topics in detail and practice what you learn.&lt;/li&gt;
&lt;li&gt;Multiple answer questions will tell you how many answers are correct. If in a questions, 2 answers are correct, the question will specify that 2 answers are correct out of the n number of choices. This helps narrow down the answers for these types of questions. &lt;/li&gt;
&lt;li&gt;Keep an eye on the remaining time. If there are questions that are taking too much time, you can flag them and come back to them later. This technique is effective in avoiding time constraints towards the end of your exam. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Well, if you've made it till here, I hope this guide will prove useful to you in some way. Do remember to read the latest official exam guide as the exam instructions may change. With this advice, I wish you the best of luck! Thank you for reading. &lt;/p&gt;

</description>
      <category>aws</category>
      <category>career</category>
      <category>cloudskills</category>
      <category>guide</category>
    </item>
    <item>
      <title>How I created a CD pipeline for Firebase RemoteConfig using GitHub actions</title>
      <dc:creator>Anshaj Khare</dc:creator>
      <pubDate>Sun, 24 Jan 2021 19:45:56 +0000</pubDate>
      <link>https://dev.to/anshaj/how-i-created-a-cd-pipeline-for-firebase-remoteconfig-using-github-actions-2i4j</link>
      <guid>https://dev.to/anshaj/how-i-created-a-cd-pipeline-for-firebase-remoteconfig-using-github-actions-2i4j</guid>
      <description>&lt;p&gt;&lt;span&gt;Photo by &lt;a href="https://unsplash.com/@quinten149?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Quinten de Graaf&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/pipeline?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://firebase.google.com/docs/remote-config" rel="noopener noreferrer"&gt;Firebase Remote Config&lt;/a&gt; is a service that lets you change the data that your web/mobile application uses without the need for a new deployment. This service can also help with &lt;a href="https://firebase.google.com/docs/ab-testing/?gclid=Cj0KCQiA0rSABhDlARIsAJtjfCfqrNh6ZcbKBEC1XW2Ff43MBQd4GcB8xkPRhVHfiHK6nAPRa18Hph0aAkb4EALw_wcB" rel="noopener noreferrer"&gt;A/B testing&lt;/a&gt; which is another really useful service provided by firebase.&lt;/p&gt;

&lt;p&gt;Firebase Remote Config console allows you to edit and publish variables through an intuitive UI. It also allows you to update these variables through a REST API. I wanted to create a solution that had the following properties - &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Other developers are able to push updates to remote config through a CI/CD system based on git&lt;/li&gt;
&lt;li&gt;Avoid having to manage users through google cloud IAM&lt;/li&gt;
&lt;li&gt;Update a google sheet, every time new updates are pushed to the firebase remote config &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I've documented the steps that you may need to follow to set up a similar CI/CD pipeline for your remote config workflow. As of the writing of this post, Firebase CLI does not support the deployment of remote-config values. The same architecture can be extended to any other firebase service that does not have native CLI support. &lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Setting up the admin account credentials
&lt;/h3&gt;

&lt;p&gt;In order to set up a continuous deployment pipeline, you'll need a service account key from the Firebase Console. This is how it can be obtained. Navigate to Settings -&amp;gt; Project Settings -&amp;gt; Service accounts. Select "Generate new private key" to generate a private key for the next steps. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note: This key enables access to your firebase project. Do not share this key or directly add it to your version control&lt;/strong&gt;. We'll look at a way to securely use this key from our CD pipeline, in the next steps.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkira2rjitd5ohur8j1x0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkira2rjitd5ohur8j1x0.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up your repository
&lt;/h3&gt;

&lt;p&gt;I've added the starter code in this &lt;a href="https://gist.github.com/anshajk/2ac022116732d7e2c0b3f9a66a0841c4" rel="noopener noreferrer"&gt;github gist&lt;/a&gt;. The repository can be set up with a virtual environment and the dependencies can be installed with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Let's try a local deployment first
&lt;/h3&gt;

&lt;p&gt;The code uses two environment variables for programmatically interacting with firebase. They are&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;PROJECT_ID&lt;/li&gt;
&lt;li&gt;CREDENTIALS&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The PROJECT_ID points to your firebase project. The same can be exported with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export PROJECT_ID=&amp;lt;your-firebase-project-id&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The CREDENTIALS variable needs to contain the information that's present in the json file containing your service account details. The same can be exported to your shell using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export CREDENTIALS=$(cat service-account.json) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order to test whether the service account credentials have been properly exported, you can print the CREDENTIALS variable with &lt;code&gt;echo CREDENTIALS&lt;/code&gt; and confirm that the contents of the service account json file are indeed present in the variable. &lt;/p&gt;

&lt;p&gt;With our environment variables set up, we can now test whether we're able to make authenticated API calls to Firebase Remote Config. From your shell, running the following command should work without any errors&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python remote_config_manager.py --action=versions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you have the ability to interact with Firebase Remote Config REST API. &lt;/p&gt;

&lt;h3&gt;
  
  
  Creating your remote config variables
&lt;/h3&gt;

&lt;p&gt;The remote config variables can be added in &lt;code&gt;remoteconfig.template.json&lt;/code&gt; or any other file that you reference in the &lt;code&gt;_publish&lt;/code&gt; method of the code. The key thing to note here is that this file will be responsible for all the variables you store and update in remote config. This is where a logic can be written to update the most-recent value in google sheets or any other system for better accessibility/visibility. &lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up the continuous deployment pipeline
&lt;/h3&gt;

&lt;p&gt;In order to set up a CD pipeline on GitHub, we'll store our PROJECT_ID and CREDENTIALS as repository secrets. For this, we'll navigate to settings in our GitHub repository and add the two values in the secrets section. This is what the end result should look like.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fomg1jmg0cmoiuvp36o02.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fomg1jmg0cmoiuvp36o02.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After setting up the secrets for your pipeline, all we're left to do is to set up our workflow using the &lt;a href="https://gist.github.com/anshajk/2ac022116732d7e2c0b3f9a66a0841c4#file-cd-yaml" rel="noopener noreferrer"&gt;cd.yaml&lt;/a&gt; file. This file will need to be present at &lt;code&gt;./github/workflows/&lt;/code&gt; in your repository in order to GitHub to trigger this as a GitHub action.&lt;/p&gt;

&lt;p&gt;After this, the following will happen - &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Every commit will trigger the build step. This is where additional steps of json validation can be added.&lt;/li&gt;
&lt;li&gt;Every commit to the main branch (from a PR or otherwise) will result in the values present at &lt;code&gt;remoteconfig.template.json&lt;/code&gt; being deployed directly to your project's remote config. You may wish to setup notifications regarding informing you of updates. You may also want to disable direct push to the main branch to avoid accidents.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;In this post I've summarised how I created a CD pipeline for Firebase Remote Config in order to save up on my time and to enable git based version control for my remote config values. I found using &lt;a href="https://github.com/features/actions" rel="noopener noreferrer"&gt;GitHub Actions&lt;/a&gt; really intuitive and the build &amp;amp; deploy process was very fast, especially with dependency caching. Maybe I'll explore GitHub Actions for more use cases going forward with my projects.  &lt;/p&gt;

</description>
      <category>firebase</category>
      <category>github</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Docker for data science and engineering</title>
      <dc:creator>Anshaj Khare</dc:creator>
      <pubDate>Thu, 13 Aug 2020 18:08:17 +0000</pubDate>
      <link>https://dev.to/anshaj/docker-for-data-science-and-engineering-5567</link>
      <guid>https://dev.to/anshaj/docker-for-data-science-and-engineering-5567</guid>
      <description>&lt;p&gt;Working as a data scientist, I had only heard of containerization. This was the case until I ended up working on a project that required shipping model training and deployment in containers on one of the cloud platforms. That's how I came across docker and it has been an integral part of my toolbox ever since. &lt;/p&gt;

&lt;p&gt;I've mentioned some of the excellent resources for getting docker below &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/softchris/5-part-docker-series-beginner-to-master-3m1b"&gt;5 part docker series from beginner to master&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/akanksha_9560/docker-for-frontend-developers-1dk5"&gt;Docker for front-end developers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this series, I'll cover docker from a data science and data engineering perspective which makes docker a very handy asset in your data science or software development toolkit. &lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Before we learn what docker is, an important question to answer is why do we need docker? &lt;/p&gt;

&lt;p&gt;Docker lets us create a completely reproducible environment. We specify the libraries that you need along with their specific versions. Docker lets us create an environment that will run the same way, irrespective of the system it's run on. This can lead to a lot of time-saving in projects with multiple environments, developers, testers, etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are containers?
&lt;/h3&gt;

&lt;p&gt;I think the official documentation on docker does a very good job of explaining what containers are. &lt;/p&gt;

&lt;p&gt;A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.&lt;br&gt;
Container images become containers at runtime and in the case of Docker containers - images become containers when they run on &lt;a href="https://www.docker.com/products/container-runtime"&gt;Docker Engine&lt;/a&gt;. Available for both Linux and Windows-based applications, containerized software will always run the same, regardless of the infrastructure. Containers isolate software from its environment and ensure that it works uniformly despite differences for instance between development and staging.&lt;/p&gt;
&lt;h2&gt;
  
  
  How can docker help with data science?
&lt;/h2&gt;

&lt;p&gt;Let's talk about an end-to-end data science solution. A data science project often involves a whole team of data scientists, data engineers, software architects, often working along with other software development teams to create a viable solution. You can have a situation where different data scientists end up working with different versions of the library only to realize after hours of debugging that there are small differences in their environments. Docker lets you create a consistent environment for data scientists and data engineers to deal with these kinds of situations. &lt;/p&gt;

&lt;p&gt;Okay, so we know now that how docker helps in maintaining consistency of the environment, but what if you work alone? Should you invest time learning and implementing docker for small scale projects? The answer is yes and I'll explain why.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ease of model building - Dockerizing your data science project can help set things up faster. I'll demonstrate this with an example below.&lt;/li&gt;
&lt;li&gt;Deployment - You've created a state of the art model with data science libraries and now you wish to create a solution out of it. Deploying a data science solution is much easier with docker in place. I'll demonstrate an example of this as well in later posts in this series. &lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Lets look at some examples
&lt;/h2&gt;

&lt;p&gt;Let's use docker to set up a data science environment for ourselves. The image that I'll set up is a jupyter notebook using docker to set up python, R and Julia with just a few commands. The image is developed and maintained by the jupyter team and the same can be found &lt;a href="https://jupyter-docker-stacks.readthedocs.io/en/latest/using/selecting.html"&gt;here&lt;/a&gt;. We need to run the following commands from a shell in your system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker pull jupyter/datascience-notebook:latest
docker run -p 8888:8888 jupyter/datascience-notebook:latest
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Navigate to &lt;code&gt;localhost:8888&lt;/code&gt; on your filesystem and copy the auth token from the shell and there you have it, you can have a data science environment to run R, python, and Julia code.&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BYeRjx-G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/m8ujhqqe9gwqfvov2iwj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BYeRjx-G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/m8ujhqqe9gwqfvov2iwj.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's see a slightly more technical use case. We'll implement a server with fastAPI. For more details, please refer the &lt;a href="https://fastapi.tiangolo.com/"&gt;FastAPI documentation.&lt;/a&gt; &lt;br&gt;
Let's see how easy it is to set up a fastAPI server on your local machine. Run the following commands from a shell in your machine in a new folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m venv venv
source venv/bin/activate
pip install fastapi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, create a &lt;code&gt;Dockerfile&lt;/code&gt; with the following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7

COPY ./app /app
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, create a folder named &lt;code&gt;app&lt;/code&gt; and create a script inside with the name &lt;code&gt;main.py&lt;/code&gt;. Add the following code to &lt;code&gt;main.py&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: str = None):
    return {"item_id": item_id, "q": q}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, go to your shell and run the following from the project root&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t myimage .
docker run -d --name mycontainer -p 80:80 myimage
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Navigate to &lt;code&gt;http://127.0.0.1/docs&lt;/code&gt; to see the &lt;a href="https://swagger.io/tools/swagger-ui/"&gt;swagger UI&lt;/a&gt; docs for the API&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PyzC6Wr8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xf5mw7cn9xi5f63li7bq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PyzC6Wr8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xf5mw7cn9xi5f63li7bq.png" alt="swagger docs"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Navigate to &lt;code&gt;http://127.0.0.1/redoc&lt;/code&gt; for &lt;a href="https://redocly.github.io/redoc/"&gt;redoc&lt;/a&gt; based docs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SL6Qs59e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gpdd19qrdax5tft8b1c8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SL6Qs59e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gpdd19qrdax5tft8b1c8.png" alt="reDocs"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a later post, I'll demonstrate how to serve your machine learning model with &lt;a href="https://fastapi.tiangolo.com/"&gt;FastAPI&lt;/a&gt; but for now, we have a FastAPI server served in docker container ready to be shipped anywhere.&lt;/p&gt;

&lt;p&gt;In this post, I demonstrated how Docker can be used in data science projects. In my next post, I'll go into more detail into docker terms and docker commands that can speed up your development process. Thanks for reading! &lt;/p&gt;

</description>
      <category>docker</category>
      <category>datascience</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How I built a zero cost serverless scraper </title>
      <dc:creator>Anshaj Khare</dc:creator>
      <pubDate>Mon, 13 Jul 2020 18:12:28 +0000</pubDate>
      <link>https://dev.to/anshaj/how-i-built-a-zero-cost-completely-serverless-scraper-20io</link>
      <guid>https://dev.to/anshaj/how-i-built-a-zero-cost-completely-serverless-scraper-20io</guid>
      <description>&lt;p&gt;I started working on a data science project with a friend, where we wanted to understand the sentiments of people about a few topics over a period of time. Naturally, the first part of building a project like this involves scraping data from the web. Since the time period for this project spans over months, we needed a way to automatically scrape data at regular intervals without any intervention. &lt;br&gt;
If you want to skip the details and need to see the code, scroll to the bottom of the page. &lt;/p&gt;

&lt;h2&gt;
  
  
  Schedulers
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Cron
&lt;/h3&gt;

&lt;p&gt;The first thing that comes to mind when talking about schedulers is cron. The trusty, reliable, all-purpose cron has been with us for a very long time and a lot of projects with simpler scheduling requirements still use corn in production systems. But cron requires a Linux server to run. We could've set up a serverless container or used a small VM with Linux for our purpose but we didn't because of the alternative that we found.&lt;/p&gt;

&lt;h3&gt;
  
  
  Airflow
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://airflow.apache.org/"&gt;Apache Airflow&lt;/a&gt; deserves a post of its own and I'm planning to write about it in the future. Simply put, Airflow is an open-source workflow orchestration tool that helps data engineers make sense of production data pipelines. In today's world, where data fuels a lot of applications, the reliability and maintainability of airflow pipelines leave little to be desired. Airflow executes tasks in DAGs (Directed Acyclic Graphs) where each node is a task and these tasks execute in the order that we specify. It's possible to run airflow in a distributed setting to scale it up for production requirements. But airflow is too much for small projects and it ends up adding overhead to a fast-paced light development process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cloud Scheduler
&lt;/h3&gt;

&lt;p&gt;This is one of the less known features of google cloud and is the service that we used in our project. &lt;a href="https://cloud.google.com/scheduler"&gt;Cloud scheduler&lt;/a&gt; is a serverless offering of cron by google cloud. In the free tier, google lets you schedule 3 jobs for free. Note that an execution instance is different from a job which means that you can schedule 3 processes for any cron schedule. We wanted our process to run every hour and hence the trusty schedule of &lt;code&gt;0 * * * *&lt;/code&gt; (more info &lt;a href="https://crontab.guru/"&gt;here&lt;/a&gt;) was implemented on the cloud scheduler.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scraping
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Lets scrape twitter
&lt;/h3&gt;

&lt;p&gt;There is an excellent Python package for scraping twitter that can be found &lt;a href="https://github.com/bisguzar/twitter-scraper"&gt;here&lt;/a&gt;. I used this to extract the data for the hashtags that we wanted to collect the data for. &lt;/p&gt;

&lt;h3&gt;
  
  
  Google cloud functions
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://cloud.google.com/functions"&gt;Google cloud functions&lt;/a&gt; are a serverless offering by google. A variety of tasks can be performed with these serverless functions but in this post, I'll only talk about how I used them to scrape data from twitter.&lt;/p&gt;

&lt;p&gt;This is what happens in the cloud function&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The keyword list is downloaded from a GCS bucket&lt;/li&gt;
&lt;li&gt;The keyword list is used to scrape the tweets from twitter&lt;/li&gt;
&lt;li&gt;The tweets are stored as a csv file in GCS again&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I made my script compatible with the requirements of cloud functions, set up the invoking method to an HTTP call and added some code to store data in a google cloud storage bucket. That was it! The serverless function was ready to do some web scraping. &lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting everything
&lt;/h2&gt;

&lt;p&gt;Now that I had a serverless scheduler and a cloud function, all I had to do was connect these two. This was fairly simple. Cloud scheduler allows us to send a post request at the interval that we want. All we needed to do was to give it the right permissions to invoke the cloud function (cloud functions should not be publically invokable)  And we had it,  a completely serverless scraper that scrapes the web at regular schedules and allows us to build excellent datasets for our use case at zero expense. &lt;/p&gt;

&lt;p&gt;Here is the &lt;a href="https://gist.github.com/fulcrum3/de395ec643693ed4b0fb825668113287"&gt;gist&lt;/a&gt; of the source code. If you found this post useful, consider following me here as I plan to write more about data engineering and data science in the upcoming weeks. &lt;/p&gt;

</description>
      <category>python</category>
      <category>googlecloud</category>
      <category>datascience</category>
      <category>serverless</category>
    </item>
    <item>
      <title>Scraping Twitter data using python for NLP tasks</title>
      <dc:creator>Anshaj Khare</dc:creator>
      <pubDate>Tue, 14 Apr 2020 10:13:53 +0000</pubDate>
      <link>https://dev.to/anshaj/scraping-twitter-data-using-python-for-nlp-tasks-2je7</link>
      <guid>https://dev.to/anshaj/scraping-twitter-data-using-python-for-nlp-tasks-2je7</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;"In God we trust. All others must bring data." - W. Edwards Deming&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you're starting in the incredible field of NLP, you'll want to get your hands dirty with real textual data that you can use to play around with the concepts you've learned. Twitter is an excellent source of such data. In this post, I'll be presenting a scraper that you can use to scrape the tweets of the topics that you're interested in and get all nerdy once you've obtained your dataset. &lt;br&gt;
&lt;br&gt;I've used this amazing library that you can find &lt;a href="http://github.com/bisguzar/twitter-scraper"&gt;here&lt;/a&gt;. I'll go over how to install and use this library and also suggest some methods to make the entire process faster using parallelization. The complete notebook containing the code can be found &lt;a href="https://jovian.ml/fulcrum3/twitter-scraper"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;The library can be installed using pip3 using the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;pip3 &lt;span class="nb"&gt;install &lt;/span&gt;twitter_scraper
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Creating a list of keywords
&lt;/h2&gt;

&lt;p&gt;The next task is to create a list of keywords that you want to use for scraping twitter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# List of hashtags that we're interested in
&lt;/span&gt;&lt;span class="n"&gt;keywords&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'machinelearning'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'ML'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'deeplearning'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
            &lt;span class="s"&gt;'#artificialintelligence'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'#NLP'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'computervision'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'AI'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
            &lt;span class="s"&gt;'tensorflow'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'pytorch'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"sklearn"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"pandas"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"plotly"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
            &lt;span class="s"&gt;"spacy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"fastai"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'datascience'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'dataanalysis'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Scraping tweets for one keyword
&lt;/h2&gt;

&lt;p&gt;Before we run our program to extract all the keywords, we'll run our program with one keyword and print out the fields that we can extract from the object. In the code below, I've shown how to iterate over the returned object and print out the fields that you want to extract. You can see that we have the following fields that we extract &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tweet ID&lt;/li&gt;
&lt;li&gt;Is a retweet or not&lt;/li&gt;
&lt;li&gt;Time of the tweet&lt;/li&gt;
&lt;li&gt;Text of the tweet&lt;/li&gt;
&lt;li&gt;Replies to the tweet&lt;/li&gt;
&lt;li&gt;Total retweets&lt;/li&gt;
&lt;li&gt;Likes to the tweet&lt;/li&gt;
&lt;li&gt;Entries in the tweet
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Lets run one iteration to understand how to implement this library
&lt;/span&gt;&lt;span class="n"&gt;tweets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;get_tweets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"#machinelearning"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;tweets_df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# Lets print the keys and values obtained
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tweets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Keys:'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt; &lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;break&lt;/span&gt;

&lt;span class="c1"&gt;# Running the code for one keyword and extracting the relevant data
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tweets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s"&gt;'text'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'text'&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt;
                    &lt;span class="s"&gt;'isRetweet'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'isRetweet'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                    &lt;span class="s"&gt;'replies'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'replies'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                    &lt;span class="s"&gt;'retweets'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'retweets'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                    &lt;span class="s"&gt;'likes'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'likes'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
                    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="n"&gt;tweets_df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tweets_df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ignore_index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;tweets_df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Running the code sequentially for all keywords
&lt;/h2&gt;

&lt;p&gt;Now that we've decided what kind of data we want to store from our object, we'll run our program sequentially to obtain the tweets of topics we're interested in. We'll do this using our familiar for loop to go over each keyword one by one and store the successful results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# We'll measure the time it takes to complete this process sequentially
&lt;/span&gt;&lt;span class="o"&gt;%%&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="n"&gt;all_tweets_df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tqdm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;keywords&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="n"&gt;tweets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;get_tweets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tweets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;    
      &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s"&gt;'hashtag'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                        &lt;span class="s"&gt;'text'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'text'&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt;
                        &lt;span class="s"&gt;'isRetweet'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'isRetweet'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                        &lt;span class="s"&gt;'replies'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'replies'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                        &lt;span class="s"&gt;'retweets'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'retweets'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                        &lt;span class="s"&gt;'likes'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'likes'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
                      &lt;span class="p"&gt;})&lt;/span&gt;
      &lt;span class="n"&gt;all_tweets_df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;all_tweets_df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ignore_index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; 
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;':'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;continue&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ax4dTIbf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/x6x8x6mv0kbfj6m4dmm8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ax4dTIbf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/x6x8x6mv0kbfj6m4dmm8.png" alt="markdown table" width="500"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Running the code in parallel
&lt;/h2&gt;

&lt;p&gt;From the &lt;a href="https://docs.python.org/3/library/multiprocessing.html"&gt;documentation&lt;/a&gt;, Multiprocessing is a package that supports spawning processes using an API similar to the threading module. The multiprocessing package offers both local and remote concurrency, effectively side-stepping the Global Interpreter Lock by using subprocesses instead of threads. Due to this, the multiprocessing module allows the programmer to fully leverage multiple processors on a given machine.&lt;/p&gt;

&lt;p&gt;First, we'll implement a function to scrape the data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# We'll create a function to fetch the tweets and store it for us
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fetch_tweets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="n"&gt;tweet_df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="n"&gt;tweets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;get_tweets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tweets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;    
      &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s"&gt;'hashtag'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                        &lt;span class="s"&gt;'text'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'text'&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt;
                        &lt;span class="s"&gt;'isRetweet'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'isRetweet'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                        &lt;span class="s"&gt;'replies'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'replies'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                        &lt;span class="s"&gt;'retweets'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'retweets'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                        &lt;span class="s"&gt;'likes'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'likes'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
                      &lt;span class="p"&gt;})&lt;/span&gt;
      &lt;span class="n"&gt;tweet_df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tweet_df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ignore_index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; 
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;word&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;':'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;tweet_df&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Next, we'll create subprocesses to run our code in parallel.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# We'll run this in parallel with 4 subprocesses to compare the times
&lt;/span&gt;&lt;span class="o"&gt;%%&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;Pool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;records&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fetch_tweets&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;keywords&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gEDctCVK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0tyy2egclkdwdqkgi5dn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gEDctCVK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0tyy2egclkdwdqkgi5dn.png" alt="markdown table" width="500"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;As you can see, we reduced our process time to almost 1/4th of sequential execution. You can use this method for similar tasks and make your python code much faster. &lt;br&gt;
Good luck with the scraping!&lt;/p&gt;

</description>
      <category>python</category>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>nlp</category>
    </item>
    <item>
      <title>What's new in pandas 1.0?</title>
      <dc:creator>Anshaj Khare</dc:creator>
      <pubDate>Wed, 29 Jan 2020 15:09:07 +0000</pubDate>
      <link>https://dev.to/anshaj/what-s-new-in-pandas-1-0-215l</link>
      <guid>https://dev.to/anshaj/what-s-new-in-pandas-1-0-215l</guid>
      <description>&lt;p&gt;Pandas 1.0.0 has been released. In this post, I have compiled the list of important changes that have been made.&lt;/p&gt;

&lt;h2&gt;
  
  
  Faster df.apply()
&lt;/h2&gt;

&lt;p&gt;Apply now supports an engine key that allows the user to execute the routine using Numba instead of Cython. For rows greater than 1 million, the Numba engine can yield a significant increase in speed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dedicated string data type
&lt;/h2&gt;

&lt;p&gt;String data type is now separate from the object data type. String data type is still experimental and probably shouldn't be used in production code. But it's nice to see a dedicated string type in the dataset. Also, in cases where you need to differentiate the string and object data types in the data, this change will come in handy. &lt;/p&gt;

&lt;h2&gt;
  
  
  NA singleton to denote missing values
&lt;/h2&gt;

&lt;p&gt;Pandas used several values to represent missing data: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;np.nan for float data &lt;/li&gt;
&lt;li&gt;np.nan or None for object-dtype data &lt;/li&gt;
&lt;li&gt;pd.NaT for datetime-like data. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;pd.NA provides a “missing” indicator that can be used consistently across data types. &lt;/p&gt;

&lt;h2&gt;
  
  
  Markdown table
&lt;/h2&gt;

&lt;p&gt;The data frame can now be printed as a markdown table using &lt;code&gt;df.to_markdown()&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D-xAKjLy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ur1xyna7w3llkvmamwo4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D-xAKjLy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ur1xyna7w3llkvmamwo4.png" alt="markdown table" width="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Better summary with DataFrame.info()
&lt;/h2&gt;

&lt;p&gt;The dataframe summary now uses a more readable style &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LxuhT2ad--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/61dql8jufadikte0bkll.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LxuhT2ad--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/61dql8jufadikte0bkll.png" alt="markdown table" width="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can use &lt;code&gt;pip install pandas==1.0.0rc0&lt;/code&gt; to install pandas 1.0 into your python environment.&lt;/p&gt;

</description>
      <category>python</category>
      <category>machinelearning</category>
      <category>datascience</category>
    </item>
  </channel>
</rss>
