di v e into p y thon
play

Di v e into P y thon IN TR OD U C TION TO DATA SC IE N C E IN P - PowerPoint PPT Presentation

Di v e into P y thon IN TR OD U C TION TO DATA SC IE N C E IN P YTH ON Hillar y Green - Lerman Lead Data Scientist , Looker What y o u' ll learn Ho w to w rite and e x ec u te P y thon code w ith DataCamp Ho w to load data from a spreadsheet Ho


  1. Di v e into P y thon IN TR OD U C TION TO DATA SC IE N C E IN P YTH ON Hillar y Green - Lerman Lead Data Scientist , Looker

  2. What y o u' ll learn Ho w to w rite and e x ec u te P y thon code w ith DataCamp Ho w to load data from a spreadsheet Ho w to t u rn data into bea u tif u l plots INTRODUCTION TO DATA SCIENCE IN PYTHON

  3. Sol v ing a m y ster y w ith data INTRODUCTION TO DATA SCIENCE IN PYTHON

  4. Using the IP y thon shell INTRODUCTION TO DATA SCIENCE IN PYTHON

  5. Using the script editor INTRODUCTION TO DATA SCIENCE IN PYTHON

  6. What is a mod u le ? Gro u ps related tools together Makes it eas y to kno w w here to look for a partic u lar tool Common e x amples : matplotlib pandas scikit-learn scipy nltk INTRODUCTION TO DATA SCIENCE IN PYTHON

  7. Importing pandas and matplotlib import pandas as pd from matplotlib import pyplot as plt # Pandas loads our data df = pd.read_csv('ransom.csv') # Matplotlib plots and displays plt.plot(df.letters, df.frequency) plt.show() INTRODUCTION TO DATA SCIENCE IN PYTHON

  8. Importing a mod u le Importing a Mod u le import pandas Importing a mod u le w ith an alias import pandas as pd INTRODUCTION TO DATA SCIENCE IN PYTHON

  9. Let ' s practice ! IN TR OD U C TION TO DATA SC IE N C E IN P YTH ON

  10. Creating v ariables IN TR OD U C TION TO DATA SC IE N C E IN P YTH ON Hillar y Green - Lerman Lead Data Scientist , Looker

  11. Filing a missing p u pp y report name = "Bayes" height = 24 weight = 75.5 INTRODUCTION TO DATA SCIENCE IN PYTHON

  12. R u les for v ariable names M u st start w ith a le � er No spaces or special (u s u all y lo w ercase ) characters Case sensiti v e ( my_var is A � er � rst le � er , can u se di � erent from MY_VAR ) le � ers / n u mbers /u nderscores # Valid Variables # Invalid Variables bayes_weight bayes-height b bayes! bayes42 42bayes INTRODUCTION TO DATA SCIENCE IN PYTHON

  13. Error messages bayes-height = 3 File "<stdin>", line 1 bayes-height = 3 ^ SyntaxError: can't assign to operator INTRODUCTION TO DATA SCIENCE IN PYTHON

  14. Floats and strings � oat : represents an integer or decimal n u mber height = 24 weight = 75.5 string : represents te x t ; can contain le � ers , n u mbers , spaces , and special characters name = 'Bayes' breed = "Golden Retriever" INTRODUCTION TO DATA SCIENCE IN PYTHON

  15. Common string mistakes Don ' t forget to u se q u otes ! Witho u t q u otes , y o u' ll get a name error . owner = DataCamp File "<stdin>", line 1, in <module> owner = DataCamp NameError: name 'DataCamp' is not defined Use the same t y pe of q u otation mark . If y o u start w ith a single q u ote , and end w ith a do u ble q u ote , y o u' ll get a s y nta x error . fur_color = "blonde' File "<stdin>", line 1 fur_color = "blonde' ^ INTRODUCTION TO DATA SCIENCE IN PYTHON

  16. Displa y ing v ariables name = "Bayes" height = 24 weight = 75 print(height) 24 INTRODUCTION TO DATA SCIENCE IN PYTHON

  17. Let ' s practice ! IN TR OD U C TION TO DATA SC IE N C E IN P YTH ON

  18. What is a f u nction ? IN TR OD U C TION TO DATA SC IE N C E IN P YTH ON Hillar y Green - Lerman Lead Data Scientist , Looker

  19. A f u nction is an action INTRODUCTION TO DATA SCIENCE IN PYTHON

  20. F u nctions in code import pandas as pd from matplotlib import pyplot as plt df = pd.read_csv('letter_frequency.csv') plt.plot(df.letter_index, df.frequency, label='Ransom') plt.show() F u nctions perform actions : pd.read_csv() t u rns a cs v � le into a table in P y thon plt.plot() t u rns data into a line plot plt.show() displa y s plot in a ne w w indo w INTRODUCTION TO DATA SCIENCE IN PYTHON

  21. INTRODUCTION TO DATA SCIENCE IN PYTHON

  22. Anatom y of a f u nction : f u nction name F u nction Name : Starts w ith the mod u le that the f u nction " li v es " in ( plt ) Follo w ed b y the name of the f u nction ( plot ) F u nction name is al w a y s follo w ed b y parentheses () INTRODUCTION TO DATA SCIENCE IN PYTHON

  23. Anatom y of a f u nction : positional arg u ments Positional Arg u ments : These are inp u ts to a f u nction ; the y tell the f u nction ho w to do its job Order ma � ers ! INTRODUCTION TO DATA SCIENCE IN PYTHON

  24. Anatom y of a f u nction : ke yw ord arg u ments Ke yw ord Arg u ments : M u st come a � er positional arg u ments Start w ith the name of the arg u ment ( label ), then an eq u als sign ( = ) Follo w ed b y the arg u ment ( Ransom ) INTRODUCTION TO DATA SCIENCE IN PYTHON

  25. Common f u nction errors Missing commas bet w een arg u ments Missing closed parenthesis INTRODUCTION TO DATA SCIENCE IN PYTHON

  26. Let ' s practice ! IN TR OD U C TION TO DATA SC IE N C E IN P YTH ON

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend