Tuesday, 19 May 2020

Pandas Built in Data Visualization | python crash course_05

Pandas Built in Data Visualization:

Welcome to python crash course tutorial, today we will see the last topic Pandas Built in Data Visualization in the data science section.
SOME INTRODUCTION:
Data Visualizations is the presentation of data in graphical format. It help people understand the significance of data by summarizing and presenting a huge amount of data in a simple and easy-to-understand format and help communicate information clearly and effectively.
In this tutorial, we will learn about pandas built-in capabilities for data visualizations. It is built-off of matplotlib, but it baked into pandas for easier usage.
Let’s take a looks
Example:
Basic Plotting: plot


This functionality on Series and DataFrame is just a simple wrapper around the matplotlib libraries plot() methods.
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(10,4),index=pd.date_range('1/1/2000',
periods=10), columns=list('ABCD'))
df.plot()
Output:
Basic Plotting
If the index consists of dates, it calls gct().autofmt_xdate() to format the x-axis as shown in the above illustration.
We can plots one column versus another using the x and y keywords.
Plotting method allow a handful of plot styles other than the default line plot. These method can be provided as the kind keyword argument to plots(). These include −
  1. bar or barh for bar plots
  2. hist for histogram
  3. box for boxplot
  4. 'area' for area plots
  5. 'scatter' for scatter plots
(Note: For detailed information please click here)
                                                   
                                                               BEST OF LUCK!!!



Sunday, 17 May 2020

Dictionary Part 3 | Python

Topics covered: 1)pop method in Dictionary in Python 2)delete statement in Dictionary in Python 3)clear method in Dictionary in Python Prerequisite: Dictionary | Python | Castor Classes https://www.youtube.com/watch?v=yZTR5... Dictionary Part 2 | Python | Castor Classes https://www.youtube.com/watch?v=qU1dV... Python for beginners: https://www.youtube.com/watch?v=egq7Z...



Telegram: https://t.me/clcoding_python
https://www.facebook.com/pirawenpython
https://www.facebook.com/groups/pirawenpython/

Dictionary Part 2 | Python

Topics covered: 1)How to print Dictionary 2)How to add / append key value pairs in dictionary 3)Update a Dictionary using Assignment Prerequisite: Dictionary | Python | Castor Classes https://www.youtube.com/watch?v=yZTR5... Python for beginners: https://www.youtube.com/watch?v=egq7Z...


Telegram: https://t.me/clcoding_python
https://www.facebook.com/pirawenpython/
https://www.facebook.com/groups/pirawenpython/


Dictionary | Python

QUIZ on List | Python

QUIZ on TUPLE | PYTHON

Efficient way to compute prefix sum | Python

Prerequisite:
https://www.youtube.com/watch?v=ESVXW... Check this link for more detail explanation of this powerful algorithm: https://en.wikipedia.org/wiki/Prefix_sum Python for beginners: https://www.youtube.com/watch?v=egq7Z...

Code: l=eval(input()); i=1; output=[]; output.append(l[0]); prefixsum=l[0]; while(i<len(l)): prefixsum=prefixsum+l[i]; output.append(prefixsum); i=i+1; print(output)




Telegram: https://t.me/clcoding_python
https://www.facebook.com/pirawenpython/
https://www.facebook.com/groups/pirawenpython/


Prefix sum | Python

Friday, 15 May 2020

What is Seaborn in data visualization? | python crash course_04

What is Seaborn in data visualization?

Hello everyone,  In the Previous blog we see first part of data visualization (Matplotlib) This blog is related to Seaborn. so Let's start:

Keys Feature

  1. Seaborns is a statistical plotting library
  2. It has beautiful default style
  3. It also is designed to work very well with Pandas dataframe object.

Installing and getting started:

To install the latest release of seaborn, you can use:
pip install seaborn
conda install seaborn
Alternatively, you can used pip to install the development version directly from github:
pip install git+https://github.com/mwaskom/seaborn.git
Another option would be to to clone the github repository and install from yours local copy:
pip install . Python 2.7 or 3.5+


Let's see examples of Bar plot:

Bar Plots

The barplots() shows the relation between a categorical variable and a continuous variable. The data is represented in rectangular bar where the length the bar represent the proportion of the data in that category.


Bar plots represents the estimate of central tendency. Let us use the ‘titanic’ dataset to learn bar plot.

Example

import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
df = sb.load_dataset('titanic')
sb.barplot(x = "sex", y = "survived", hue = "class", data = df)
plt.show()

Output:

barplot

(Note: for detailed please click here )

                                              BEST OF LUCK!!!!!





Thursday, 14 May 2020

Reverse a string using Stack | Python

Prerequisite: Reverse First K elements of Queue using STACK | Python | Castor Classes https://www.youtube.com/watch?v=gqIA2... Python for beginners: https://www.youtube.com/watch?v=egq7Z...

Code: def reverse(string): #Add code here stack=[]; for i in string: stack.append(i); s=""; i=0; while(i<len(string)): s=s+stack.pop(-1); i=i+1; return s;





Telegram: https://t.me/clcoding_python
https://www.facebook.com/pirawenpython/
https://www.facebook.com/groups/pirawenpython/

Reverse First K elements of Queue using STACK | Python

Prerequisite: Stacks and Queues using List | Data Structures | Python | Castor Classes https://www.youtube.com/watch?v=bMVBW... Python for beginners: https://www.youtube.com/watch?v=egq7Z...
Code:


def reverseK(queue,k,n):
    # code here
    stacka=[];
    queue2=queue[k:];
    i=0;
    while(i<k):
        f=queue.pop(0);
        stacka.append(f);
        i=i+1;
    queue=[];
    i=0;
    while(i<k):
        f=stacka.pop(-1);
        queue.append(f);
        i=i+1;
    queue=queue+queue2;
    return queue


Telegram: https://t.me/clcoding_python
https://www.facebook.com/pirawenpython/
https://www.facebook.com/groups/pirawenpython/

Wednesday, 13 May 2020

What is Matplotlib in Data Visualization? | Python crash course_03

What is Matplotlib in Data Visualization?

Hello everyone, welcome to Python crash course. Today I am going to Explain What is Matplotlib in Data Visualization? Let's Start:

Introduction about Matplotlib:
A pictures is worth a thousand word, and with Python’s matplotlib library, it, fortunately, take far less than a thousand words of code to create a production-quality graphic.However, matplotlibs is also a massive library, and getting a plot to looks just right is often achieved through trial and error. Using one-liners to generate basic plot in matplotlib is fairly simple, but skillfully commanding the remaining 97% of the library can be daunting.
This articles is a beginner-to-intermediate-level walkthrough on matplotlib that mixe theory with example. While learning by example can be tremendously insightful, it helps to have even just a surface-level understanding of the library’s inner working and layout as well.
SOME EXAMPLE OF MATPLOTLIB:
In this chapter, we will learn how to create a simple plots with Matplotlib.
We shall now display a simple line plots of angle in radians. its sine values in Matplotlib. To begin with, the Pyplot module from Matplotlib package is imported, with an alias plot as a matter of convention.
import matplotlib.pyplot as plt
Next we need an array of number to plot. Various array function are defined in the Numpy library which is imported with the np alias.
import numpy as np
We now obtain the ndarray object of angle between 0 and 2π using the arange() function from the Numpy library.
x = np.arange(0, math.pi*2, 0.05)
The ndarray object serves as values on x axis of the graphs. The corresponding sine values of angles in x to be displayed on y axis are obtained by the following statements −
y = np.sin(x)
The value from two arrays are plotted using the plot() functions.
plt.plot(x,y)
You can set the plots title, and labels for x and y axes.
#You can set the plots title, and labels for x and y axes.
plt.xlabel("angle")
plt.ylabel("sine")
plt.title('sine wave')


The Plots viewer window is invoked by the show() function −
plt.show()
The complete programs is as follow −
from matplotlib import pyplot as plt
import numpy as np
import math #needed for definition of pi
x = np.arange(0, math.pi*2, 0.05)
y = np.sin(x)
plt.plot(x,y)
plt.xlabel("angle")
plt.ylabel("sine")
plt.title('sine wave')
plt.show()
Simple Plot

FOR DETAILED PLEASE OPEN BELOW LINK:
                                           BEST OF LUCK!!!!!!


Tuesday, 12 May 2020

Reshape the Matrix | Python

Problem Statement:

In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data.

You're given a matrix represented by a two-dimensional array, and two positive integers r and c representing the row number and column number of the wanted reshaped matrix, respectively.

The reshaped matrix need to be filled with all the elements of the original matrix in the same row-traversing order as they were.

If the 'reshape' operation with given parameters is possible and legal, output the new reshaped matrix; Otherwise, output the original matrix.

Example 1:
Input:
nums =
[[1,2],
 [3,4]]
r = 1, c = 4
Output:
[[1,2,3,4]]
Explanation:
The row-traversing of nums is [1,2,3,4]. The new reshaped matrix is a 1 * 4 matrix, fill it row by row by using the previous list.
Example 2:
Input:
nums =
[[1,2],
 [3,4]]
r = 2, c = 4
Output:
[[1,2],
 [3,4]]
Explanation:
There is no way to reshape a 2 * 2 matrix to a 2 * 4 matrix. So output the original matrix.
Note:
The height and width of the given matrix is in range [1, 100].
The given r and c are all positive.


Code:

class Solution:
    def matrixReshape(self, nums: List[List[int]], r: int, c: int) -> List[List[int]]:
        k=len(nums);
        m=len(nums[0]);
        if(k*m==r*c):
            l=[];
            for i in nums:
                l=l+i;
            i=0;
            j=0;
            output=[];
            k=[];
            temp=0;
            while(i<r):
                while(j<c):
                    k.append(l[temp]);
                    temp+=1;
                    j=j+1;
                output.append(k);
                k=[];
                j=0;
                i=i+1;
            return output;
        else:
            return nums;

All About Pandas in Data Science | python crash course_02

All About Pandas in Data Science:

Hello friend, Today I am going to explain What is pandas in Data Science? so Let start:
This tutorial has been prepared for those who seek to learn the basic and various functions of Pandas. It will specifically useful for people working with data cleansing and analysis. After completing this tutorial, you will find yourself at moderate level of expertise from where you can take yourself to higher level of expertise.
Pandas is an open-source, BSD-licen Python library providing high-performance, easy-to-use data structures and data analysis tool for the Python programming language. Python with Pandas is used in wide range of field including academic and commercial domain including finance, economic, Statistic, analytics, etc. In this tutorial, we will learn the various feature of Python Pandas and how to use them in a practice.
Pandas deals with the following three data structure 
Series
DataFrame
Panel
These data structure are built on top of Numpy array, which mean they are fast.
Standard Python distribution doesn not come bundled with Pandas module. A lightweight alternative is install Numpy using popular Python package installer, pip.
pip install pandas 
import pandas as pd

SOME EXAMPLE OF PANDAS LIBRARY:
There are two kind of sorting available in Pandas. They are 
  • 1.By label
  • 2.By Actual Value
import pandas as pd
import numpy as np

unsorted_df=pd.DataFrame(np.random.randn(10,2),index=[1,4,6,2,3,5,9,8,0,7],colu
mns=['col2','col1'])
print unsorted_df

OUTPUT:

        col2       col1
1  -2.063177   0.537527
4   0.142932  -0.684884
6   0.012667  -0.389340
2  -0.548797   1.848743
3  -1.044160   0.837381
5   0.385605   1.300185
9   1.031425  -1.002967
8  -0.407374  -0.435142
0   2.237453  -1.067139
7  -1.445831  -1.701035

From 3D ndarray (FOR PANEL CREATION)


import pandas as pd
import numpy as np

data = np.random.rand(2,4,5)
p = pd.Panel(data)
print p
output:

<class 'pandas.core.panel.Panel'>
Dimensions: 2 (item) x 4 (major_axis) x 5 (minor_axis)
Items axis: 0 to 1
Major_axis axis: 0 to 3
Minor_axis axis: 0 to 4



FOR DETAIL PLEASE DRIVE LINK:
https://drive.google.com/open?id=1RKv0v0V9kfvMceWb2QHdWfavDffsGAgV
FOR MORE DETAILED ABOUT PANDAS PLEASE OPEN BELOW LINK:



Popular Posts

Categories

100 Python Programs for Beginner (49) AI (34) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (173) C (77) C# (12) C++ (82) Course (67) Coursera (226) Cybersecurity (24) data management (11) Data Science (128) Data Strucures (8) Deep Learning (20) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (34) Hadoop (3) HTML&CSS (47) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (59) Meta (22) MICHIGAN (5) microsoft (4) Nvidia (3) Pandas (4) PHP (20) Projects (29) Python (929) Python Coding Challenge (354) Python Quiz (22) Python Tips (2) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (3) Software (17) SQL (42) UX Research (1) web application (8) Web development (2) web scraping (2)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses