Tuesday, August 30, 2022

Usefull Pandas Statical Formula

 #data.sex.describe()

Describinf sing Column


#data.std()
For Standard Deviation

#Skewness and Kurtosis

print(skew(data.pollution_exp, axis=0, bias=True))
print(kurtosis(data.pollution_exp, axis=0, bias=True))

Some Usefull Pandas Formula

 # data.info()

use for displaying Column Name,[Data type], null/Non/Null


#data.describe().T
use to display Mean,Median Mode, Percentile,Min and max Value

#data.corr().style.background_gradient(cmap='coolwarm')
use to Display and Calculate Correlation among Columns,

#data.isna()
for finding null value in columns

#data.isna().sum()

for displaying total null values in columns


#data['classification'].unique()

to display Unique Value

#data[['classification','id']].groupby('classification').count()

to display Count value group by naother column


#data.drop(['id','rbc'],axis=1,inplace=True)
droping Columns

#data['age'].mean()

calculating Mean of Column

#data['dm'].replace(to_replace = {' yes':'yes'},inplace=True)

replacing a value with another value


#data['appet'].fillna( data['appet'].mode()[0], inplace=True)

Filling Null Value with Mode


# for col in data.columns:
    print(f"{col} has {data[col].unique()} values\n")


Displaying all columns Unique Value



#
g = sns.PairGrid(data)
g.map_diag(plt.hist)
g.map_offdiag(plt.scatter)

Displaying Pair Plot


#sns.catplot(x="classification", y="age",data=data,hue='appet',col='htn')

Displaying Category Plot


#sns.boxplot(x='htn',y='age',data=notchk_age)

Displaying Box Plot

Google Drive access from Google Colab

 import pandas as pd



from google.colab import drive
drive.mount('/content/drive')

data= pd.read_csv('/content/drive/MyDrive/DataScience/Content/kidney_disease.csv')
data.head()

Monday, August 24, 2015

Context Menu in Jquery

 contextMenu.js
contextMenu.css


$.contextMenu({
    selector: '#tblAmendGrid tr:gt(0)',
    callback: function (key, options) {
        switch (key) {
            case 'Delete':
                deleteAmendmentInfo($(this).children('td:eq(0)').text());
                break;
        }
    },
    items: {
        "Delete": { name: "Delete", icon: "edit" }
    }

});

Wednesday, June 17, 2015

design pattern

http://www.oodesign.com/
https://sourcemaking.com/design_patterns

Friday, June 5, 2015

Datediff in sql in hour minute second

insert into [DBL_Group].[dbo].[tblGmMachineZeroHour]( fldDate,                  fldOrderNo,     fldUnit,   [fldLine], fldMachineName, fldMachineQty,fldReasonKey,fldFrom,   [fldTo],   fldTotalTime,[fldReason])
SELECT
     Cast( fldDate  as Date),  [fldOrderNo],   [fldUnit],    [fldLine],[fldMachineName],[fldMachineQty],[fldReasonKey], [StartProblem],[Confirmation],
     CAST(DATEADD(MINUTE,DATEDIFF(MINUTE,[StartProblem],[Confirmation]),'1900-01-01 00:00:00.000') AS Datetime)   ,
    
     [fldReason]   
    
  FROM [DBL_Group].[dbo].[tblGmMachineZeroHourTest]   where [StartProblem] is not null and  [Confirmation] is not null
  and  DATEDIFF(Day,[StartProblem],[Confirmation])<1 and fldReasonKey is not null

Tuesday, May 26, 2015

Uploading Image to Server using jquery c#

    $("#avatarUpload").on('change', function () {

        previewFile();
    });

    var imgBase64;
    function previewFile(evt) {
        // var preview = document.querySelector('#<%=Avatar.ClientID %>');
       // var files = evt.target.file;
        var preview = document.getElementById('avatarImg');
        //$('#avatarImg');
      //  var file = document.querySelector('#avatarUpload').files[0];
        var input = document.getElementById('avatarUpload');
        var dv = document.getElementById('showImg');
        var file = input.files[0];
        console.log(file);
        var reader = new FileReader();

        reader.onloadend = function () {
            preview.src = reader.result;
            dv.value = reader.result;
            imgBase64 = reader.result;
            imgBase64 = imgBase64.replace('data:image/png;base64,', '');
            imgBase64 = imgBase64.replace('data:image/gif;base64,', '');
           // console.log(btoa(reader.result))
        }

        if (file) {
           // alert('file found');
             reader.readAsDataURL(file);
           // reader.readAsArrayBuffer(file)

           // reader.readAsBinaryString(file);
        } else {
            preview.src = "";
        }
    }



       // var image = document.getElementById("avatarImg").toDataURL("image/png");
     var   image = imgBase64.replace('data:image/jpeg;base64,', '');

        $.ajax({
            type: "POST",
            url: base + "TPWL/InsertImage",
            dataType: "JSON",
            data: JSON.stringify({ "obj": image }),
            contentType: "application/json;charset=utf-8",
            success: function (data) {
                console.log(data);
                if (data.ResultID != '-1') {
                    $("#spInfo").html('<strong style="color:green">' + data.Message + '</strong>');
                    $("#tblDetails tr:gt(0)").remove();
                    if (data.obj != null) {
                        AppenHeadData(data.obj.OrderHead);
                        AppendDetailsTable(data.obj.OrderDetailsDetails)
                    }
                }
                else {
                    $("#spInfo").html('<strong style="color:red">' + data.Message + '</strong>');
                }


            },
            error: function (a, b, c) {
                alert(a + '..' + c.statusCode);
                // alert(a.statusText);
            }

        });


    });


<div style=" text-align:center;">
    <input id="avatarUpload" type="file" name="files[]" accept="image/*" />
    <img width="60" height="60" src="123.jpg" id="avatarImg" />

    <input type="button"  value="Image Upload" id="tbnImgUpload"/>

    <textarea id="showImg"></textarea>
</div>