PySpark Tutorial for Beginners: What is PySpark & How to Use It Locally?

Akansha Yadav walks through PySpark basics and local setup. PySpark is Python's API for Apache Spark, used by Netflix, YouTube, Uber, and Amazon for fast distributed data processing. The tutorial covers installing Java and PySpark, configuring VS Code and Jupyter, and initializing PySpark on your machine.
Chapters
is the use of PySpark, how you can utilize PySpark. Now, in terms of utilizing, as I told you, you can handle big data. Hello everyone, welcome back to my YouTube channel. In today's video, we are going to discuss about what exactly PySpark is and how to use this if you are into the domain of data analysis, data science, machine learning or data engineering, how you can utilize PySpark for your processing things. So now let's understand what exactly PySpark is, where it originated from. So now in simple term, PySpark is something which supports Python, which works within Python. So it is going to support Python, and within this, within Python, this is Python API, okay? And this comes from the term which is— this is, uh, from the Apache Spark. So Apache Spark is basically a tool which helps you process large amount of data quickly, right? So PySpark is the smaller version or the direct version of Apache Spark which can be used, which can be written, which can be processed within Python. So in short, PySpark is a Python API for Apache Spark using which you can do big data processing, and it acts as a big data processing engine where you can handle large data set faster than any traditional tool. Earlier we were using Pandas, we were using other polar libraries of Python, right? But these two libraries can process the data which is less amount of data, not a huge amount of data. If you are trying to do something with a huge amount of data, these libraries are going to take more time. So we have the advanced version, we have the version of library which is PySpark, which can process big data, which can analyze huge amount of data quickly because it can distribute the workload across multiple computers. We will understand this term, that how it distributes the workload across multiple computer, in this video. Before we begin, this is a complete playlist where you will get to know about PySpark in detail— how to use it, how to use it for SQL, how to do data analysis, how to do data cleaning. Everything we are going to learn within this playlist. There is a second playlist which is going on on my channel, which is Data Cleaning with Python. So both are very beneficial if you are into these domains. So now let's understand what is the use of PySpark, how you can utilize PySpark. Now in terms of utilizing, as I told you, you can handle big data. When you wanted to handle big data, PySpark should be your friend. Second is you should use this because this is super fast. So this is another benefit of PySpark. It is using PySpark, you can work with SQL, you can work with ML as well, which is machine learning. It can help you in data analysis and it can also help you in building AI tools, AI models at scale. Now why should you learn it if you are aiming for a better future? So for future proof, this is used by big companies as well. Big companies, as I mean that I can say that it is used by Netflix, it is used by Uber, and these days Amazon is also using this PySpark for doing real-time analysis. Okay, so that is why you should learn PySpark in 2025. Now let's understand some basic things that why this PySpark, why not other traditional things. So when I talk about comparison between PySpark and any other traditional things that we have been using, any traditional method that we have been using till now. First thing is, suppose you want one person to copy something, you know, one person is doing something and it is going to obviously take long time, right? But if you are going to give the same task and you are going to allot 100 person Okay, in total 100% you wanted to allot, and the same task, then this is what PySpark is. PySpark basically divides the task into subtasks and will allot it to the multiple machines, and will allot it to the multiple machines so that the job is done much faster. So this is how PySpark works. In traditional method, we are the single person, like suppose we are using pandas. So using Pandas, you are going to take long time to do the same thing which you can do within PySpark within few seconds. So this is how PySpark speeds up the data processing. Basically, it splits the work across multiple machines, across multiple servers. That is why PySpark is able to achieve things faster. As I have given you a few examples that these days companies are using PySpark. First example, let's consider of Netflix, or let's say YouTube. On which you are viewing this video, right? So if I talk about Netflix and YouTube, Netflix and YouTube recommend videos and movies based on your past watching history, right? So it means that it is able to process your history, whether it is of 10 years, 20 years, or it is of just 2 years. So PySpark— using PySpark, Netflix and YouTube are able to process that data. Second example which I gave you was Uber. Similar company that we have is Ola. Ola and Uber are able to analyze millions of rides daily to predict the demand and also to optimize the route. So for both of the things, it is using— for both of the things, it is using PySpark to analyze and give you the best in terms of routes and to serve the demand as well. Third is, let's talk about the sector which is banking sector. How banking sector is utilizing the— in banks, the banks uses PySpark to track the suspicious transactions in real time, that what is going on, which one is the suspicious transaction. Everything within this is done using PySpark. Fourth example that we can take is of e-com, which is again trending these days in 2025. So those suggestions of products come from PySpark only because PySpark knows how to You know, go with your history or preferences and print and display the perfect one for you as per your preference. So it is high in demand, it has growing market, and you should learn this because it has growing market. If you know PySpark, you can easily get job, and there are more job opportunities if you are going to learn this. Correct. Now let's talk about how to set it up. So PySpark needs some tools and software. First thing that's by PySpark need is Java. You should have Java on your system. If you have Java, you can easily download PySpark on your system. And I am going to tell you how exactly you have to do it within multiple things, like how you can use it within Jupyter Notebook, how you can use it in the Visual Studio Code, and how to verify the installation as well. Everything we are going to discuss in this particular video. Now let's talk about installation. So as I said, you have to do what is— you have to get Java on your system. So simply you have to open one browser and search for Java official site, Java official website, okay? Once you will search for Java official website, you will land on something like this. So you need to download Java for your Windows, Mac, or Linux, whichever software or whichever operating system you are using, you have to download it as per 32 bits and 64 bits. Now once you have downloaded this, what you need to do is you need to go to CMD and you have to type one command to check whether the Java is completely installed on your system or not. So just type java space hyphen version. So this is going to show you the version of Java that you have on your system. So for me it is 1.8.0_381. This is the version which I have downloaded on my system. Once you have done this, your next task is that you have to install PySpark on your system. So as I am going to use this Visual Studio Code for my coding purpose and for, you know, explaining also, I'm going to do this. So I'm just going to create one new file within this data cleaning folder itself. So now let's say my file name is gh.ipyenv. So now you have to add one code cell and then you have to type pip install— let me just increase the size. Yes. So now you have to type pip install pyspark and just run this. It is going to connect to the kernel and going to install this library for you in this particular environment, in whichever folder or in whichever file you wanted to use it. So as I have already, you know, downloaded this PySpark, so it shows requirement already satisfied. For you, it will take few time, a few seconds of yours to install it completely on your system. Once it is done, how to verify whether it exists and how it exists, what is the exact version you are using? If you are unaware, then you just type import PySpark and then enter, and then write print bracket Same thing I'm going to write for the version over here. pyspark.__version should be your command to check the version of PySpark and then run it. It's going to tell you the version of this. Okay, I need to write version__— yeah, so it is 3.5.4 version which I am using. Now let's say you are using that Anaconda and Jupyter Notebook. Now let's suppose you are using Anaconda and Jupyter Notebook. So how to do that on that Anaconda stuff? So for that, what you need is you need one library, one more library, which is findspark. So you simply have to open that Jupyter Notebook which you have within Anaconda. I'm telling you on this interface itself, you just have to open that and then type pip install findspark. If in case you are not able to install it using pip install, you can first install findspark and then you have to initialize it within it. Now how to initialize it? I'm adding one more code cell to tell you. You just write down find— to import findspark, and then you have to say findspark initialize. Once you will initialize, once you will initialize the PySpark, then only you will be able to get it on your file. This is the complete two commands that you need to write to install it within this. Now this is the complete setup that you need for your system to work with PySpark. So I hope you found this video really interesting and informative. So don't forget to comment down if is something which you're struggling with, and I am there to help you. So we'll meet in the next video. Until then, bye-bye.










