In [1]:
import os as os

In [2]:
os.getcwd()


Out[2]:
'C:\\Users\\Dell'

In [3]:
os.chdir('C:\\Users\\Dell\\Downloads')

In [4]:
os.listdir()


Out[4]:
['140749_2017.pdf',
 '2011-F01-0700-Rev4-MDDS.XLSX',
 '20150817143155.pdf',
 '20160111060911.pdf',
 '20170214052225.pdf',
 '861415_10151432783238421_2124270505_o (1).jpg',
 '861415_10151432783238421_2124270505_o.jpg',
 'AirPassengers.csv',
 'ajayo.jpg',
 'Alison Python  Invoice   - Sheet1.pdf',
 'Alison SAS  Invoice   - Sheet1.pdf',
 'Allison Interview Jones Invoice   - Sheet1.pdf',
 'Anaconda3-4.2.0-Windows-x86_64.exe',
 'apachehttpd.exe',
 'April invoice adaptive analytics   - Sheet1.pdf',
 'Assignment14_BusinessAnalytics (1).docx',
 'Assignment14_BusinessAnalytics.docx',
 'Assignment15_BusinessAnalytics.docx',
 'Assignment16_BusinessAnalytics (1).docx',
 'Assignment16_BusinessAnalytics (2).docx',
 'Assignment16_BusinessAnalytics.docx',
 'aug ust 2008.JPG',
 'avast_free_antivirus_setup_online.exe',
 'avinash_ltv.zip',
 'BigDiamonds.csv',
 'BigDiamonds.csv (1).zip',
 'BigDiamonds.csv (2)',
 'BigDiamonds.csv (2).zip',
 'BigDiamonds.csv.zip',
 'Boston (1).csv',
 'Boston.csv',
 'CAM- Ajay Ohri (1).pdf',
 'CAM- Ajay Ohri.pdf',
 'camtasia.exe',
 'ccFraud (1).csv.crdownload',
 'ccFraud.csv',
 'Certificate of Incorporation - U74999DL2015PTC282030 (26 June 2015).pdf',
 'CHAP1-6PythonforRUsersAnapproachforDataScience.docx',
 'chapter+3+_+spark.html',
 'chi+square+test.ipynb',
 'chromeinstall-8u111.exe',
 'Cisco_WebEx_Add-On.exe',
 'class2.csv',
 'Collabera Invoice (1).pdf',
 'Collabera Invoice.pdf',
 'Collectcent Invoice.pdf',
 'college degrees.pdf',
 'DAP 1.pdf',
 'DAP 1.pptx',
 'DAP 6 RDBMS and SQL.pdf',
 'DAP 6 RDBMS and SQL.pptx',
 'data+exploration.ipynb',
 'data+manipulation.ipynb',
 'data1.csv',
 'datasets.csv',
 'Decision Trees.pdf',
 'DecisionStatsOfferLetter.docx',
 'DecisionStatsRelievingLetter.docx',
 'descriptive+stats+in+Python.ipynb',
 'desktop.ini',
 'Diamond (1).csv',
 'Diamond (2).csv',
 'Diamond (3).csv',
 'Diamond (4).csv',
 'Diamond (5).csv',
 'Diamond (6).csv',
 'Diamond.csv',
 'DropboxInstaller.exe',
 'edb_npgsql.exe',
 'edb_pgjdbc.exe',
 'edb_psqlodbc.exe',
 'edb_psqlodbc.exe-20170203172812',
 'edb_psqlodbc.exe-20170307203617',
 'final invoice edureka  - Sheet1.pdf',
 'FinalPythonforRUsersAnapproachforDataScience (1).docx',
 'FinalPythonforRUsersAnapproachforDataScience (2).docx',
 'FinalPythonforRUsersAnapproachforDataScience (3).docx',
 'FinalPythonforRUsersAnapproachforDataScience (4).docx',
 'FinalPythonforRUsersAnapproachforDataScience.docx',
 'final_webinar (1).pdf',
 'final_webinar.pdf',
 'Git-2.11.0-64-bit.exe',
 'Git-2.12.0-64-bit.exe',
 'GitHubSetup (1).exe',
 'GitHubSetup (2).exe',
 'GitHubSetup.exe',
 'GOMAUDIOGLOBALSETUP.EXE',
 'HP Downloads',
 'HPSupportSolutionsFramework-12.5.32.203.exe',
 'image.png',
 'IMS PROSCHOOL Workshop.pptx.pdf',
 'IMS PROSCHOOL Workshop.pptx.pptx',
 'Introduction to SAS (1).pdf',
 'Introduction to SAS Part 1 (1).pdf',
 'Introduction to SAS Part 1.pdf',
 'Introduction to SAS.pdf',
 'Invoice for Digital Vidya.pdf',
 'Invoice for Weekendr.pdf',
 'Invoice format - Ajay Ohri CONTATA (1).xls',
 'Invoice format - Ajay Ohri CONTATA.xls',
 'invoice rapid miner.pdf',
 'iris2 (1).ipynb',
 'iris2 (2).ipynb',
 'iris2.ipynb',
 'January invoice Indicus  .pdf',
 'June AV   Invoice   - Sheet1.pdf',
 'Lecture 6 - KNN & Naive Bayes.ppt',
 'Local Disk (C) - Shortcut.lnk',
 'logistic regression - script for ppt.R',
 'logistic_regression_-_script_for_ppt.html',
 'March invoice Indicus   - Sheet1.pdf',
 'mongodb-win32-x86_64-2008plus-ssl-3.4.2-signed.msi',
 'mongodb-win32-x86_64-3.4.2-signed.msi',
 'mtcarslm.R',
 'nltk.ipynb',
 'notebook-Copy1.html',
 'Offer Letter - Ajay Ohri (1).pdf',
 'Offer Letter - Ajay Ohri.pdf',
 'Other Data Mining  Methods (1).pdf',
 'Other Data Mining  Methods.pdf',
 'output1 (1).xls',
 'output1 (2).xls',
 'output1.xls',
 'passport image.pdf',
 'Pawconinvoice2016.pdf',
 'Pawconinvoice2017 (1).pdf',
 'Pawconinvoice2017 (2).pdf',
 'Pawconinvoice2017 (3).pdf',
 'Pawconinvoice2017.pdf',
 'Payslip Feb 2016 - Sheet1.pdf',
 'Payslip Feb 2016.pdf',
 'Payslip Format Decisionstats - Sheet1.pdf',
 'Payslip Jan 2016 - Sheet1.pdf',
 'Payslip Jan 2016.pdf',
 'Payslip March 2016 - Sheet1.pdf',
 'Payslip March 2016.pdf',
 'pgd.csv',
 'postgresql-9.6.1-1-windows-x64.exe',
 'Program 1-results.rtf',
 'protein.csv',
 'python+with+postgres (1).ipynb',
 'python+with+postgres.ipynb',
 'R-3.3.2-win.exe',
 'R-3.3.3-win.exe',
 'RCertificationExam.pdf',
 'reg+model.ipynb',
 'Revision -  Business Analytics (1).pdf',
 'Revision -  Business Analytics.pdf',
 'RidingMowers.csv',
 'rsconnect',
 'RStudio-1.0.136.exe',
 'Salary Slip, Feb 2016.pdf',
 'Salary Slip, Jan 2016.pdf',
 'Salary Slip, March 2016 (1).pdf',
 'Salary Slip, March 2016 (2).pdf',
 'Salary Slip, March 2016.pdf',
 'sales-of-shampoo-over-a-three-ye.csv',
 'SAS part 2.pdf',
 'SAS Part 3.pdf',
 'sas-university-edition-107140.pdf',
 'Scan0095.pdf',
 'Scanned Invoice for Collabera.pdf',
 'Screenshot 2017-01-23 12.36.55.png',
 'September invoice adaptive analytics   - Sheet1.pdf',
 'Sollers January.pdf',
 'sqlalchemy.ipynb',
 'stackoverflow-dump-analysis.html',
 'Sunstone.pdf',
 'Tableau.pdf',
 'TableauPublicDesktop-64bit-10-1-3.exe',
 'TableauPublicDesktop-64bit-10-1-4.exe',
 'telecom.csv',
 'TelecomServiceProviderCaseStudy.pdf',
 'Text Mining (1).pdf',
 'Text Mining.pdf',
 'third.sas7bdat',
 'Time Series  Forecasting (1).pdf',
 'Time Series  Forecasting.pdf',
 'ts.html',
 'ts.R',
 'Unconfirmed 373974.crdownload',
 'Unconfirmed 376562.crdownload',
 'Unconfirmed 376991.crdownload',
 'Unconfirmed 930917.crdownload',
 'Unconfirmed 950045.crdownload',
 'unvbasicvapp__9411008__ova__en__sp0__1.ova.crdownload',
 'VirtualBox-5.1.8-111374-Win (1).exe',
 'VirtualBox-5.1.8-111374-Win.exe',
 'Webinar for Business Analytics.pdf',
 'WhatsApp Image 2017-02-18 at 08.42.55 (1).jpeg',
 'WhatsApp Image 2017-02-18 at 08.42.55.jpeg']

In [5]:
import pandas as pd

In [6]:
cfraud=pd.read_csv("ccFraud.csv")

In [7]:
cfraud.head()


Out[7]:
custID gender state cardholder balance numTrans numIntlTrans creditLine fraudRisk
0 1 1 35 1 3000 4 14 2 0
1 2 2 2 1 0 9 0 18 0
2 3 2 2 1 0 27 9 16 0
3 4 1 15 1 0 12 0 5 0
4 5 1 46 1 0 11 16 7 0

In [8]:
cfraud.describe()


Out[8]:
custID gender state cardholder balance numTrans numIntlTrans creditLine fraudRisk
count 1.000000e+07 1.000000e+07 1.000000e+07 1.000000e+07 1.000000e+07 1.000000e+07 1.000000e+07 1.000000e+07 1.000000e+07
mean 5.000000e+06 1.382177e+00 2.466127e+01 1.030004e+00 4.109920e+03 2.893519e+01 4.047190e+00 9.134469e+00 5.960140e-02
std 2.886751e+06 4.859195e-01 1.497012e+01 1.705991e-01 3.996847e+03 2.655378e+01 8.602970e+00 9.641974e+00 2.367469e-01
min 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 1.000000e+00 0.000000e+00
25% 2.500001e+06 1.000000e+00 1.000000e+01 1.000000e+00 0.000000e+00 1.000000e+01 0.000000e+00 4.000000e+00 0.000000e+00
50% 5.000000e+06 1.000000e+00 2.400000e+01 1.000000e+00 3.706000e+03 1.900000e+01 0.000000e+00 6.000000e+00 0.000000e+00
75% 7.500000e+06 2.000000e+00 3.800000e+01 1.000000e+00 6.000000e+03 3.900000e+01 4.000000e+00 1.100000e+01 0.000000e+00
max 1.000000e+07 2.000000e+00 5.100000e+01 2.000000e+00 4.148500e+04 1.000000e+02 6.000000e+01 7.500000e+01 1.000000e+00

In [17]:
cfraud.balance.describe()


Out[17]:
count    1.000000e+07
mean     4.109920e+03
std      3.996847e+03
min      0.000000e+00
25%      0.000000e+00
50%      3.706000e+03
75%      6.000000e+03
max      4.148500e+04
Name: balance, dtype: float64

In [11]:
pd.value_counts(cfraud.fraudRisk)


Out[11]:
0    9403986
1     596014
Name: fraudRisk, dtype: int64

In [12]:
pd.value_counts(cfraud.gender)


Out[12]:
1    6178231
2    3821769
Name: gender, dtype: int64

In [14]:
pd.crosstab(cfraud.gender,cfraud.fraudRisk)


Out[14]:
fraudRisk 0 1
gender
1 5853053 325178
2 3550933 270836

In [13]:
pd.value_counts(cfraud.state)


Out[13]:
5     1216069
44     812638
10     608630
35     608575
39     405892
15     404720
36     364531
23     304553
11     303984
29     303833
32     284428
46     252812
43     203827
16     203143
25     203045
48     202972
4      202776
21     202444
20     201918
49     182557
24     182201
6      171774
2      162574
41     152253
19     151715
18     142170
37     122191
38     121846
7      121802
13     111775
26     101829
3      101740
45      91375
34      91326
17      91127
33      81332
50      61385
14      60992
28      60617
12      50438
22      40819
31      40563
9       30333
40      30233
27      30131
51      20691
8       20603
42      20449
30      20215
1       20137
47      20017
Name: state, dtype: int64

In [ ]: