Search the Blog

Sunday, September 22, 2019

Data Science Plot example with Real data Complete with Code

Python Data Science Learning

This post is dedicated to the new developer which are in starting phase Data Science Learning.

In this Post i have develop a graph of a organization  for analysis of the costing of organization. In Starting Phase i have used only two paramaters of Coasting one is Sale and Second is Purchase. Both Sale and Purchase are always constant part of any organization whether it is production or service or any kind of organization.

I will Explain the Complete Topic in following Points-

Step 1- Import the Pandas Dataframe Library.



# parameters and libraray which is imported 
# pandas for dataframe
import pandas as pd

#pyodbc for sql server 
import pyodbc 


Step 2- Define the server Name and location and database name


DB = {
            'servername': '103.27.100.100',
            'database': 'DIZSWEB'
          }

Step 3- Create the Connection String to database


# create the connection with SQL Server
conn = pyodbc.connect(
   'DRIVER = {SQL Server};
    SERVER ='  + DB['servername'] + ';
    DATABASE = ' + DB['database']+';
    UID = DIZSWEB;
    PWD = DIZSWEB;
    Trusted_Connection = no'
)

Step 4- Create the Query


# Sales Query of the organization
Sales = "SELECT CO_CODE, 
               Month(INV_DATE) as INV_DATE,                                                   sum(Acc_Total_Amount) 
               FROM invoice_mast 
               where CO_CODE='DIZSWEB' and                                                   Acc_Total_Amount>0 
               group by CO_CODE, 
               Month(INV_DATE) 
               order by Month(INV_DATE);"


# Purchase Query of the organization
Purchase = "SELECT CO_CODE,
                    Month(Pur_Voucher_Date) as Pur_Voucher_Date,
                    sum(Acc_Main_Total_Amount) 
                    FROM Purchase_Main_mast 
                    where CO_CODE='DIZSWEB' 
                    group by CO_CODE, 
                    Month(Pur_Voucher_Date) 
                    order by Month(Pur_Voucher_Date);"


Step 5- Reading of SQL Query into DataFrame


#Reading the Sales sql query data into pandas datafrme
Sales_df = pd.read_sql(Sales, conn)

#Reading the Purchase sql query data into pandas datafrme
Purchase_df = pd.read_sql(Purchase, conn)

Step 6- Testing of Data

   To Test the data of DataFrame following two cmd is used 


       # Print the first 5 rows of Sales_df
          Sales_df.head(5)
       # Then Press Shift+Enter


Python data Science Project with Live DataSet

      # Print the first 5 rows of Purchase_df
         Purchase_df.head(5)
      # Then Press Shift+Enter
python data science live data example

Step 7- Renamaing of Column

  Column Renaming will help us to merge the data into a single DataFrame for analysis.


# Then rename the Column Name 
    Sales_df.rename(columns={
                                  "":"CR_Amount",
                                  "CO_CODE":"Comapany",                                                                "INV_DATE":"Date"
                                   }, inplace = True);
# Test Again 
Sales_df

# Then rename the Column Name 
Purchase_df.rename(columns=
                                 {
                                   "":"DR_Amount",                                                                               "CO_CODE":"Comapany", 
                                   "Pur_Voucher_Date":"Date"
                                  }, inplace = True);
# Test Again
Purchase_df

Step 8- Merging of datainto a single DataFrame


# Now Join the two dataframe in this tutotial i have merge the data frame on left outer join of sql type 
result = pd.merge
               ( 
                Sales_df, 
                Purchase_df, 
                how='left', 
                on=['Date','Comapany']
               )
# I have store the data into a new varible that is result

# Print the result again Shift+Enter
result

Data Science - DataFrame Merging

Step 9- Importing of MatplotLib for graph Ploting


# Now i am goin to plot the data for this i am importing two lybrary
# matplotlib pyplot
# dates beacuse my data will be ploated according to the baseis of date
        import matplotlib.pyplot as plt
        import matplotlib.dates as dates
        %matplotlib inline

Step 10- Defining the Axis and Parametere and variable


# define of combine dataframe
df=pd.DataFrame(
                            { 
                             'x': result.Date, 
                             'y1': result.CR_Amount, 
                             'y2': result.DR_Amount
                             }
                             )

           plt.plot( 
                       'x', 'y1', 
                       data=df, 
                       marker='o', 
                       markerfacecolor='blue', 
                       markersize=1, 
                       color='skyblue', 
                       linewidth=1
                      )
           plt.plot( 
                      'x', 'y2', 
                      data=df, 
                      marker='', 
                      color='olive', 
                      linewidth=1
                      )
plt.legend()

Step 11- Final Plot of data


Organization Costing via python and pandas

After analysis of the graph i found that in starting of Indian financial year sell of the organization was on a constant pace and their was enough profit to the organizasation on the basis of current data but as the session passes the sale of the organization goes downward. So now we have to analysis the factor of  sales degradation it could be the government, environment, company product issues, market issue, Season is not suitable for the product.
Competor increament, Costing is increasing because of that orzanization reduce production.



Wednesday, September 18, 2019

Purchase To Pay - New Item Creation

Item Opening in any Organization is very important phase because if proper structure and process is not followed then a single item can have multiple name and multiple location of storage and different rate and different value. Matching of such items can not be easy always.


Demerits of Wrong Item Name and Code opening.
1- Recourse Miss Usage- 
Same Item Can have multiple Storage Location
2- Loss To Company- 
Item exists in Store with XYZ name but the user          department calls the Item with ABC Name. So in          Emergency case already available item will be indent or purchased again.
   
3- Costing –
Same item with different name and rate will effect the                  organization costing.
   4- Quality - 
        Same Item with different name and purchased from                          different Supplier will have different quality                                      parameters.
   5- User confusion-
        A old user may be familiar to the name of item but a new                   joined user will not able to distinguish the products.
   6- Taxes Losses-
        U supplier may sell the item in X taxation's and V                              supplier  may sell the item in Y taxation's. So it will be 
        loss to company and comes in category of fraud in   b                        Government.


Merits of Single Item Name In Organization.
   1- Zero Recourse Miss Usage- 
        In Emergency condition, Item can be track in various                        location of organization
   2- Zero Loss to Company- 
        Item have the Common name with Standard and all user                  will be familiar with that, Because Standard is followed                    in Name Creation So new user will also be familiar with                  that.
   3- Costing -
           Single item Costing will be always easy
   4- Quality - 
       Standard parameter is defined for item So quality                             compromises is not possible at the time of purchase.
   5- User confusion-
       Standard is followed so confusion to user will be Zero.
   6- Taxes Losses-
        Standard is followed so no taxes issues will occur. 


Types of Items in Organization with respect to Purchase and Store.
1- Consumables/ Salable Items.
2- Service Item
3- Asset Item.


Consumables/ Salable Items.

Those which effect our Stock directly.
Those items which can be used once only are called Consumables Items. 
Those items which is sold is called salable Items.
 

Consumables Items are various type such as:-
   1- Raw Material
   2- Electrical Machinery
   3- Mechanical Machinery
   4- Office 
   5- Computer
   6- Cleaning

Theses are some categories even the users or respected organization can distribute the items into various subgroup according to usage to specify the location and consumption of item and make costing of the item easier.

   Example- Raw Material 
        Definition - All those material on which by doing some                     mac hing or performing some process a new Item is produced is called RAW Material.
   
   Now If i am working in Organization where Finish Good is           produced from 5 Separate Semi-Finish Good then fro these 5 different Semi- Finish Goods we have different RAW Material So we can separate our RAW Material on the basis of process or naming of machining or something else.
  Advantage of doing this will be help to analysis the costing of different process and optimization of Utilization.

Service Items- 
Those items which do not have physical existence but have cost effect on company.
   Like:- Employee Salary, 
              Machine Repairing Service, 
              Software Services.
              Third Party Audit Service.


Asset Items:-  
Those Items which have its Value in market and increases or decreases its cost with time. 
     Like:- Land of Company,
                Machines.


Item Master Creation Process
Now the Important part of this topic is what are the points which should be in consideration before creating the item master of any organization.

Item Master of any Organization may change according to work and process. But some important points should be consideration.

Primary (Mandatory)
   1- Item Code 
   2- Item Name (Standard Process)  
   3- Unit of Measurement
   4- Type of Item(Con, Service, Asset)
   5- Tax

Secondary
   1- Group of Item 
   2- Local Name of Item
   3- Secondary Measurement Unit.
   4- Unit Price
   5- Storage Location/Usage Location
                               
Tertiary
   1- Weight
   2- Minimum Stock Availability
   3- Maximum Stock  Availability
   4- Supplier Part No/ Customer Part No/ Machine Name
   5- Costing Center
   6- Peak usage Month / quarter




Sunday, September 15, 2019

Data Science Sample example for Beginner

Data Science Complete  Example with Library Pandas and Matplotlib :-

Sample Data Frame for Data Analysis in juypter with library pandas matplotlib

Learning of data Science is very easy for developer  and IT backgroud people beacuse they knows about programming mathodolgy and syntax in various other language. As java have its own set of rules for execute the program in the same way python have its own.

In this post i will explain about the code regarding to plot the data of company for april 1st week sales graph. To demonstrate that i have designed my own data set and save that data in CSV File.

Basic requirement to run this program and code are following

1- Python
2- Juypter Notebook
3- pandas 
4- matplotlib
5- dataset (In my case it is CSV File)

Python 

 I have installed Python 3.7. If you are new please download that first.


Note:- Download the python from anaconda site and download distribution version, Because with distribution version all required library will be installed, User don't need to download that separately.


To Check python is installed correctly please open cmd and run the following command.

C:\Users\HP>python
python insatllation testing

When you run the command then it will show you the currently installed version of python in your system.


Opening of Jupyter Notebook

Open the CMD and run the following command

C:\Users\HP>jupyter notebook

jupyter notenook opening via cmd prompt

Now the Screen will look Like This

Jupyter userr interface

Now The Complete Code is-
Step 1:- Defining of Pandas Lib, Numpy Lib
Defining of Pandas Lib, Numpy Lib

Step 2:- Reading the CSV File. In this Case i have the location of                  CSV File is same as of my jupyter directory
Reading the CSV File python pandas


Step 3:- Defining the Name of Columns
Defining the Name of Columns

Step 4:- Printing of read data.
Printing of read data pandas matplotlib python

Step 5:- Definng of matplotlib 
Step 6:- Creating the plot parameter 
Creating the plot parameter

Step 7:- Running of Final Code.

Translate