welcome to the co u rse
play

Welcome to the co u rse ! IN TR OD U C TION TO IMP OR TIN G DATA - PowerPoint PPT Presentation

Welcome to the co u rse ! IN TR OD U C TION TO IMP OR TIN G DATA IN P YTH ON H u go Bo w ne - Anderson Data Scientist at DataCamp Import data Flat les , e . g . . t x ts , . cs v s Files from other so w are INTRODUCTION TO IMPORTING


  1. Welcome to the co u rse ! IN TR OD U C TION TO IMP OR TIN G DATA IN P YTH ON H u go Bo w ne - Anderson Data Scientist at DataCamp

  2. Import data Flat � les , e . g . . t x ts , . cs v s Files from other so �w are INTRODUCTION TO IMPORTING DATA IN PYTHON

  3. Import data Flat � les , e . g . . t x ts , . cs v s Files from other so �w are Relational databases INTRODUCTION TO IMPORTING DATA IN PYTHON

  4. Plain te x t files INTRODUCTION TO IMPORTING DATA IN PYTHON

  5. Table data 1 So u rce : Kaggle INTRODUCTION TO IMPORTING DATA IN PYTHON

  6. Table data INTRODUCTION TO IMPORTING DATA IN PYTHON

  7. Table data Flat � le INTRODUCTION TO IMPORTING DATA IN PYTHON

  8. Reading a te x t file filename = 'huck_finn.txt' file = open(filename, mode='r') # 'r' is to read text = file.read() file.close() INTRODUCTION TO IMPORTING DATA IN PYTHON

  9. Printing a te x t file print(text) YOU don't know about me without you have read a book by the name of The Adventures of Tom Sawyer; but that ain't no matter. That book was made by Mr. Mark Twain, and he told the truth, mainly. There was things which he stretched, but mainly he told the truth. That is nothing. never seen anybody but lied one time or another, without it was Aunt Polly, or the widow, or maybe Mary. Aunt Polly--Tom's Aunt Polly, she is--and Mary, and the Widow Douglas is all told about in that book, which is mostly a true book, with some stretchers, as I said before. INTRODUCTION TO IMPORTING DATA IN PYTHON

  10. Writing to a file filename = 'huck_finn.txt' file = open(filename, mode='w') # 'w' is to write file.close() INTRODUCTION TO IMPORTING DATA IN PYTHON

  11. Conte x t manager w ith with open('huck_finn.txt', 'r') as file: print(file.read()) YOU don't know about me without you have read a book by the name of The Adventures of Tom Sawyer; but that ain't no matter. That book was made by Mr. Mark Twain, and he told the truth, mainly. There was things which he stretched, but mainly he told the truth. That is nothing. never seen anybody but lied one time or another, without it was Aunt Polly, or the widow, or maybe Mary. Aunt Polly--Tom's Aunt Polly, she is--and Mary, and the Widow Douglas is all told about in that book, which is mostly a true book, with some stretchers, as I said before. INTRODUCTION TO IMPORTING DATA IN PYTHON

  12. In the e x ercises , y o u’ ll : Print � les to the console Print speci � c lines Disc u ss � at � les INTRODUCTION TO IMPORTING DATA IN PYTHON

  13. Let ' s practice ! IN TR OD U C TION TO IMP OR TIN G DATA IN P YTH ON

  14. The importance of flat files in data science IN TR OD U C TION TO IMP OR TIN G DATA IN P YTH ON H u go Bo w ne - Anderson Data Scientist at DataCamp

  15. Flat files INTRODUCTION TO IMPORTING DATA IN PYTHON

  16. Flat files INTRODUCTION TO IMPORTING DATA IN PYTHON

  17. Flat files INTRODUCTION TO IMPORTING DATA IN PYTHON

  18. Flat files INTRODUCTION TO IMPORTING DATA IN PYTHON

  19. Flat files Te x t � les containing records That is , table data Record : ro w of � elds or a � rib u tes INTRODUCTION TO IMPORTING DATA IN PYTHON

  20. Flat files Te x t � les containing records That is , table data Record : ro w of � elds or a � rib u tes Col u mn : feat u re or a � rib u te INTRODUCTION TO IMPORTING DATA IN PYTHON

  21. Flat files Te x t � les containing records That is , table data Record : ro w of � elds or a � rib u tes Col u mn : feat u re or a � rib u te INTRODUCTION TO IMPORTING DATA IN PYTHON

  22. Header INTRODUCTION TO IMPORTING DATA IN PYTHON

  23. Header INTRODUCTION TO IMPORTING DATA IN PYTHON

  24. File e x tension . cs v - Comma separated v al u es . t x t - Te x t � le commas , tabs - Delimiters INTRODUCTION TO IMPORTING DATA IN PYTHON

  25. Tab - delimited file INTRODUCTION TO IMPORTING DATA IN PYTHON

  26. Tab - delimited file INTRODUCTION TO IMPORTING DATA IN PYTHON

  27. Ho w do y o u import flat files ? T w o main packages : N u mP y, pandas Here , y o u’ ll learn to import : Flat � les w ith n u merical data ( MNIST ) Flat � les w ith n u merical data and strings ( titanic . cs v) INTRODUCTION TO IMPORTING DATA IN PYTHON

  28. Let ' s practice ! IN TR OD U C TION TO IMP OR TIN G DATA IN P YTH ON

  29. Importing flat files u sing N u mP y IN TR OD U C TION TO IMP OR TIN G DATA IN P YTH ON H u go Bo w ne - Anderson Data Scientist at DataCamp

  30. Wh y N u mP y? N u mP y arra y s : standard for storing n u merical data INTRODUCTION TO IMPORTING DATA IN PYTHON

  31. Wh y N u mP y? N u mP y arra y s : standard for storing n u merical data Essential for other packages : e . g . scikit - learn loadt x t () genfromt x t () INTRODUCTION TO IMPORTING DATA IN PYTHON

  32. Importing flat files u sing N u mP y import numpy as np filename = 'MNIST.txt' data = np.loadtxt(filename, delimiter=',') data [[ 0. 0. 0. 0. 0.] [ 86. 250. 254. 254. 254.] [ 0. 0. 0. 9. 254.] ..., [ 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0.]] INTRODUCTION TO IMPORTING DATA IN PYTHON

  33. C u stomi z ing y o u r N u mP y import import numpy as np filename = 'MNIST_header.txt' data = np.loadtxt(filename, delimiter=',', skiprows=1) print(data) [[ 0. 0. 0. 0. 0.] [ 86. 250. 254. 254. 254.] [ 0. 0. 0. 9. 254.] ..., [ 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0.] [ 0. 0. 0. 0. 0.]] INTRODUCTION TO IMPORTING DATA IN PYTHON

  34. C u stomi z ing y o u r N u mP y import import numpy as np filename = 'MNIST_header.txt' data = np.loadtxt(filename, delimiter=',', skiprows=1, usecols=[0, 2]) print(data) [[ 0. 0.] [ 86. 254.] [ 0. 0.] ..., [ 0. 0.] [ 0. 0.] [ 0. 0.]] INTRODUCTION TO IMPORTING DATA IN PYTHON

  35. C u stomi z ing y o u r N u mP y import data = np.loadtxt(filename, delimiter=',', dtype=str) INTRODUCTION TO IMPORTING DATA IN PYTHON

  36. Mi x ed datat y pes 1 So u rce : Kaggle INTRODUCTION TO IMPORTING DATA IN PYTHON

  37. Mi x ed datat y pes INTRODUCTION TO IMPORTING DATA IN PYTHON

  38. Let ' s practice ! IN TR OD U C TION TO IMP OR TIN G DATA IN P YTH ON

  39. Importing flat files u sing pandas IN TR OD U C TION TO IMP OR TIN G DATA IN P YTH ON H u go Bo w ne - Anderson Data Scientist at DataCamp

  40. What a data scientist needs T w o - dimensional labeled data str u ct u re ( s ) Col u mns of potentiall y di � erent t y pes Manip u late , slice , reshape , gro u pb y, join , merge Perform statistics Work w ith time series data INTRODUCTION TO IMPORTING DATA IN PYTHON

  41. Pandas and the DataFrame INTRODUCTION TO IMPORTING DATA IN PYTHON

  42. Pandas and the DataFrame INTRODUCTION TO IMPORTING DATA IN PYTHON

  43. Pandas and the DataFrame DataFrame = p y thonic analog of R ’ s data frame INTRODUCTION TO IMPORTING DATA IN PYTHON

  44. Pandas and the DataFrame INTRODUCTION TO IMPORTING DATA IN PYTHON

  45. Manip u lating pandas DataFrames E x plorator y data anal y sis Data w rangling Data preprocessing B u ilding models Vis u ali z ation Standard and best practice to u se pandas INTRODUCTION TO IMPORTING DATA IN PYTHON

  46. Importing u sing pandas import pandas as pd filename = 'winequality-red.csv' data = pd.read_csv(filename) data.head() volatile acidity citric acid residual sugar 0 0.70 0.00 1.9 1 0.88 0.00 2.6 2 0.76 0.04 2.3 3 0.28 0.56 1.9 4 0.70 0.00 1.9 data_array = data.values INTRODUCTION TO IMPORTING DATA IN PYTHON

  47. Yo u’ ll e x perience : Importing � at � les in a straightfor w ard manner Importing � at � les w ith iss u es s u ch as comments and missing v al u es INTRODUCTION TO IMPORTING DATA IN PYTHON

  48. Let ' s practice ! IN TR OD U C TION TO IMP OR TIN G DATA IN P YTH ON

  49. Final tho u ghts on data import IN TR OD U C TION TO IMP OR TIN G DATA IN P YTH ON H u go Bo w ne - Anderson Data Scientist at DataCamp

  50. Ne x t chapters : Import other � le t y pes : E x cel , SAS , Stata Feather Interact w ith relational databases INTRODUCTION TO IMPORTING DATA IN PYTHON

  51. Ne x t co u rse : Scrape data from the w eb Interact w ith APIs INTRODUCTION TO IMPORTING DATA IN PYTHON

  52. Let ' s practice ! IN TR OD U C TION TO IMP OR TIN G DATA IN P YTH ON

Recommend


More recommend