DEV Community

jayson kibet
jayson kibet

Posted on

Python used in Data Analytics

Introduction

Python is simply a high-level programming language used in data analytics,web development,automation,AI and so many more fields.
It was created by Guido van Rossum and released in 1991.
I will walk you through how it's used in Data Analytics.

Why is python popular in data analytics

Python consistently ranks among the world’s most popular programming languages because it balances simplicity,power and flexibility which is often rare in programming languages.

1.Python looks simple and easy to read

Compared to other programming languages like Java or C++,Python code is much simple and usually takes fewer lines.It makes it easier for beginners to learn.


unlike java:

2.Used in data analytics

You can calculate the average of sales or anything by writing a simple piece of code:

3.It has plenty of libraries

A good example is the 'Pandas'.It lets you load a spreadsheet(or CSV file) and start exploring it immediately.

4.Productivity

Despite being slower than other languages,Python tends to be more productive since it only needa a few lines of code and as a developer,you can build a project much faster.

Python libraries used in data analytics

These are basically the tools you'll use.

1.Pandas

Pandas lets you load a spreadsheet (or CSV file) and start exploring it immediately.It is also so powerful since it helps you clean,organize,filter and analyze data with very little code.

It is widely used by data analysts and data scientists to work with tables and large datasets efficiently.Learning Pandas is one of the most important steps in becoming comfortable with data analytics using Python.

3.Numpy

Numpy handles mathematical operations.

In the above photo,i calculated the mean in less than a minute.It's incredibly useful when you're crunching hundreds of values.You can also calculate the median,standard deviation without writing loops.Another reason why analysts love it.

4.Matplotlib and Seaborn

These are the best for visualization in Python that turn your data into charts.Matplotlib is the foundation and Seaborn sits on top of it and organizes things in a nicer way with less effort.

A chart is worth a thousand numbers.These libraries turn your boring tables into something you can actually see and understand.
1.Bar charts for comparisons - plt.bar(['A','B','C'], [10,25,15]) shows which category wins.
2.Histograms for distributions - plt.hist(ages) reveals if your customers are mostly young or old.
3.Seaborn makes everything prettier - sns.barplot(data=df, x='city', y='sales') gives you professional colors and cleaner layouts without fiddling.

Using python in data cleaning,analyzing and visualizing

When you're working as a data analyst(or even just exploring data for fun),you'll follow the same process almost every time:
Clean the data,analyze the data then visualize the data

1.Data cleaning

The raw data is always full of messy stuff like duplicates,wrong capitalizaion,empty cells,wrong data types and many more.It is your job to clean it.So python allows you to clean it in a much easier way


By running that,you can save a lot of time that you could have spent in excel.


I also love python since you can save the code and still run it months later.In simple terms,i mean Excel forces you to repeat the same clicks every time.Python remembers.

2.Analyzing the data

once your data is clean,you can now solve every question you want.Python gives you answers fast and the more specific your questions,the more useful the answers become.


You don't need to memorize all these.Just know they exist.Knowing you can answer almost anything in seconds is what makes Python fun.

3.Creating visuals

Numbers in a table are hard to understand and confusing especially thousands of rows.Charts make things click immediately.


That creates a bar chart showing which regions are selling the most.When you bring a chart like that into a meeting,people get it way faster than if you'd read the numbers aloud.
You can create more than a bar graph:

fun fact:Most people in meetings don't care about your math.They care about what they can see.A clean chart does the talking for you. You just point and say"Look at this."
Once you write the code for a chart,you can reuse it on next month's data with zero extra work.

Real-world examples of python in Data Analytics

Apart from the theory part,Python is used behind the scenes in running almost every industry it the day-to-day life

1.Healthcare

Medical institutions used Python to help save lives.How?During the Covid-19 pandemic,Python helped researchers model how the virus spreads and which interventions worked best.Running on laptops,shaping public health decisions in real time.

2.Industries like Youtube and Netflix

Youtube suggests videos based on what you watch often.It's not by magic.That's Python.Without Python,you'd need a lot of humans picking videos for you manually.So how is it done?Python tracks how long you watch each video,It compares your patterns to millions of other users.Those "Up next" suggestions then Calculated in milliseconds.

3. E-commerce

A good example it those online stores.
Recommendations-"People who bought this also bought that" is pure Python work.
The Dynamic pricing:Python changes prices in real time.When it's raining,umbrella prices go up.

4. Banking and fraud detection

When your bank notices a suspicious transaction or sends you an alert at 2 am,chances are Python caught it before you even noticed something was wrong.Python builds a "normal behavior profile" for your account by learning your spending habits like buying coffee at 8 AM,paying rent on the 1st,and never spending more than

Why You Should Start Learning Python

I will be honest with you,if you are curious about working with data,whether large or small,you should start learning Python as soop as possible.According to me,it's one of the best investments of time.Pythons is so simple and beginner-friendly and you can get so many sites that can teach you more about python.
It is also a high skill in demand.You can land to any job easily and set a career path.
You can also build real things quickly.You can load an excel file,clean it and create dashboards in a few minutes.YOU can even analyze your Spotify history.
So go ahead and Open your jupyter notebook,Write "Hello." Load a file,make a mess,break things and fix them.That's the whole journey.

conclusion

You don't need to be a "math person" or a "tech person" to learn Python for data analytics.Just be curious.Most data work is loading a file,cleaning the messy parts,making a few charts and telling someone what you found.This article has explained how you do it.

Top comments (0)