Learn efficiently

If you have not read, the Pandas-Starter post in the series, here is the link.

A large chunk of a data scientist’s work revolves around data transformation. Pandas library provides various functions to transform data, aggregate data, pivot data etc. Thus making life of data scientists easier.

Let us have a look at the data we will be using as example in this post.

import pandas as pd

data = pd.read_csv("cm31MAR2021bhav.csv")
data = data.drop('Unnamed: 13',axis=1)
print("\n",data.columns)
print("\n",data.shape)
print("\n",data.head())


Host your own API.

Flask is a web application framework. It is sometimes also called a micro framework as it keeps API core very simple.

This post will mainly focus on the application of Flask framework. Here is the link to Flask documentation if you wish to know more.

I will be using Postman to test the APIs. To know more about Postman click here.

  1. Let us start with an “hello world” example of a function in Python:
def hello_world():
return "Hello World"

We can access the function over a network using Flask:

from flask import Flask app = Flask(__name__)…


What is it ?

“Data analytics is all about gaining insights from data and using it to solve a problem statement.”

It has become a part and parcel of various domains such as biological research, cosmic exploration, stock market analysis, financial management, travel planning, advertisement industry, manufacturing industry etc.

Types of data analysis:

a) Descriptive Data Analysis (What?): The amount of data under study can be humongous and to understand the aspects of it can become overwhelming. Descriptive statistics helps us in creating simple summaries which further combined with graphs and charts can be used to construct a coherent representation…


Code effortlessly.

Pandas is a python library which is mainly used for tabular data operations. It is an important part of data science toolkit. The APIs in Pandas provide a wide range of functionality and they are simple to implement.

Pandas can be installed via pip:

pip install pandas

The two main components of pandas library are ‘series’ and ‘dataframe’. Series can be thought of as a column in a table where dataframe is the table.

Let us try to create a dataframe from scratch:

import pandas as pd

dc = {
"col1": [1,2,3,4,5],
"col2": [2,3,4,5,6]
}

df = pd.DataFrame(dc)
print(df)

If we check the datatype of the ‘df’…


Code effortlessly.

Numpy stands for Numerical Python. It is the library most suited if one wishes to work with matrices, arrays, transformations etc. Its simplicity and highly efficient algorithms have made numpy a must learn library.

Let us conduct an experiment to see how numpy performs over pythons ‘for loop’ :

In the below experiment we are trying to add corresponding elements in two arrays, i.e. 1st element of one array to 1st element of second array and likewise. At the end we can compare the time taken to complete the task.

from datetime import datetime a = [2,3,4]*100000000 b…


Code effortlessly

A python class gives us structure for creating a new entity in python with methods associated with it.

Default data types in python such string, list etc. all are classes (check builtins.py).

Let us look go through some examples to clear our understanding:

  1. Creating a class
class A:
age = 4

def get_age(self):
print(A.age)

In the above example we have defined a class A and associated variable ‘age’ and method ‘get_age’ to it. Notice inside get_age method we are calling value of age as A.age which is because of the scope of variable.

# Create an instance of…


Code effortlessly

This post is regarding loops and basic functions in python. Any python programmer should be aware of these concepts.

There is difference between solving a use case and solving it with an elegant code. The word elegant here refers to a code which is simple, less number of lines, properly structured and has high maintainability. The concepts discussed in this post will help you achieve just that.

  1. Loops: Consider a situation where a coder has to repeat a set of code block a number of times, in such cases loops are very efficient. …


Code effortlessly

While solving a use-case we often encounter a need to read some data from a file or to save an output to a file (Basic Input and Output Operations). Various file formats have their own specific nuances.

Without further ado, let us dive into the pythonic pool and learn how to read and write various file formats.

  1. Text file

a. Reading a text file :- Text file(.txt) is the most common file format available. We can load a text file into python memory in the following ways:


Code effortlessly

Before you start learning basic operations you need to realize that python has its own style. Many coders find the indentation style of python very uneasy because their eyes try to find the curly braces ‘{}’ or semi colon ‘;’ at the end of the command or statement.
If you are not aware of Pycharm Editor you can through this article.

Let us get started:

  1. Open python console in your Pycharm editor as shown in the figure.

2. Since python is an interpreted language we can add two number with ease in the console.


Code effortlessly

When it comes to programming you need an integrated development environment (IDE) to code, structure,re-structure, debug etc. These softwares help us to minimize the coding effort. There are many IDEs for Python like Jupyter, Spider, Pycharm, VSCode etc. In this tutorial will focus on PyCharm IDE.

  1. Download Pycharm Community Version:
    link: https://www.jetbrains.com/pycharm/download/
    Click the download button under community section to get the open-source version or you can go with professional version (advance user). For beginners opensource version will suffice.

2. Once the download completes, open the executable file, you will see the below window. …

Shubham Saket

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store