Stats: 3,228,962 members, 8,080,586 topics. Date: Monday, 17 February 2025 at 07:40 PM |
Nairaland Forum / Science/Technology / Programming / Python For Data Science Bring You On Speed To Data Processing (963 Views)
How I Switched To Data Science From A Non IT Background - My Learning Experience / Python For Accountants / Who's Interested In Learning Python For Data Science (from Scratch) (2) (3) (4)
Python For Data Science Bring You On Speed To Data Processing by eosho: 6:57pm On Apr 28, 2020 |
Inroduction to Python: Contents: What is python and history. Installing python and python enviroment. Basic commands in Python. datatype and operations. if-then-else statement. For Loop. Python functions. Python packages. Introduction to Pyhton: Python is a general purpose language. Human readable sysntaxand well documented. Open source. Powerful Scripting Language with Simple syntax Used by many data scientist and developers History: Python was created by Guido Rossum. first version released 1991 pythin 2 released 2000. python 3 released 2008. python 3 was released to overcome future code expansion challengies Python 3 is not fully backward comaptible with Python 2. Python 2 will no longer be supported after 2020. Python 2.7 or Python 3.5 whihc version to use? Clearly Python 2 is not the same as Python 3 there are minorchanges and some incompatibilities code meant for Python 2 may not always run on Python 3 and vice versa. However, all Imprtant packages like NumPy, SciPy and MatPlotlib are availabe form both Python 2 and 3. *****Note: In this course we're going to be using Python 3 Installing Python and Python IDE: Practical Installing Anaconda. Writting and executing Python Programs: Python has many options to write and execute a program. However, we'll explore 3 main ways to execute Python Code, which include: 1.Text editor or Command Line Interface 2.Ipython 3.Any Python IDE ****** Note: we would be using SPyder IDE which is a part of Anaconda distirbution (website:https://www.anaconda.com/distribution/#download-section. ) Anaconda has all the required software Inbuilt.All on e needs is to download and install with need for elaborate configuration. Spyder IDE Spyder IDE formerly know as PYdee, is an open source cross platform IDE for python which has the following features: 1. Editor with syntax Highlightingin code completion 2. Interractive console to execute and check output of the code 3. Testing and Debugging is relativly easy 4. Best IDE if you already worked with R-studio or Matlab 5. it provides ObjectInspector that executes in the context of a console IE: Any object created can be inspected. |
Re: Python For Data Science Bring You On Speed To Data Processing by eosho: 7:29pm On Apr 28, 2020 |
Spyder Editor: ![]() To execute the code you must first highlight it then hit Ctrl + Enter. Code writen in this editor is saved in .py format. You can load old code files. You can hit tab button to show auto fill options on objects and function names. Note: you will be spending most of your time using the editor throughout this course Spyder Varriable expolrer: Shows all varialbles that are created in current session. helps in physical checking the presence of objects that are created. shows a quick summary of the presence of: type of objects, size, lenght, sample, etc. we can run the code and see the objects getting created, also we can validate the datatype and sizeof the object. Spyder Console: This is where the code will be executed, when you hit Ctrl+Enter in the Editor. Help us when we are code testing and debugging. help us to avoid errors in source code at the development phase itself. Its usual practice to write a chunk of code in editor and execute then see if its working or not from the cosole window. In Spyder IDE you can toggle between console and Ipython console. |
Re: Python For Data Science Bring You On Speed To Data Processing by Nobody: 9:07pm On Apr 28, 2020 |
Is Anaconda a text editor or an IDE? I need to know because Python wouldn't install on my laptop. I'm using my phone to learn python, with pydroid3. Should I move on and download anaconda on my laptop? It's like the Spyder console is built in? I think the Spyder console is the text editor? |
Re: Python For Data Science Bring You On Speed To Data Processing by eosho: 5:36pm On Apr 30, 2020 |
Basic commands in Python: Note: Python is case seensitive eg: address is not sames as address Also be careful while using variable names and functions eg: Print() which is wriing and is not same as pint() which is correct. TO comment a codeout you use # for single liine and """""" 3 inverted commas to comment a paragrap Basic commands: using basic mathematical commands Practice 1: 571+95 print (57+39) print ( "vibra Consulting" ) rint (phone number 08059846085) # Use hash (#) for comments # divisional examples 34/56 35/70 144/12 # thia is how yoou coment out a single line in Python. """ this is how you comment out a line in Python """ |
Re: Python For Data Science Bring You On Speed To Data Processing by eosho: 4:52pm On May 06, 2020 |
Assinging and Naming Convention: = is the Assigning operator Practice 2: income = 12000 income print (income) x=20 x y=30 y z= x*y z name="jack" name print(name) # del, this deletes the varialbe x del x Printing: # Practice 3: name = "jack" name print (name) #Note there is a diffrence in the output when using print book_name = "practical business Anlytics \n uaing SAS" book_name print (book name) Naming Convention: Must start with a letter (either upper case A-Z or lower case a-z can contain letters, digits (0-9) and underscore 1x=20 wrong x1=20 correct x.1=20 wrong x_1=20 correct Objects: Objects refer to any enitity in python Program Having a good knowledge on these basic ojects is essential to being confortable python programming Type of Objects: Numbers Stringgs List Tuples Dictionaries Practice 4: age-30 age weight=102.88 weight x=17 x**2 #ie: square of x Strings: Strings are amongst the most popular objects in Python, there are a number of method or built in string fuctions Defining name= "Sheldon" msg=statinfer Data Science Classes Acessing Strings print (name [0]) priny [name {1}] this is as good as subtring print(msg[0:9]) lenght of string len(msg) Print (msg[10:len(msg)]) list: List is a hybrid datatype. A sequence of related data, similar to array, but all elements need not ne of same type. Practice 5 #creating a list: mylist1= ['Sheldon', 'Male', 25] mylist1 #Accessing the list elements mylist1[0] mylist1[1] mylist1[2] #How to combine 2 list together mylist2= ['LA', 'no 27', CR18754] Final_List= mylist1 + mylist2 Final_List #How to change an element in the list final_list[2] =30 #How to know the length of the list elements len(Final_List) #How to delete a list del(Final_List) #How to delete elements of a list del(Final_List[5]) Tuples: A sequence types created using parenthesis rather than square brackets that can not be updated. Pracrtice #Creating a tuple my_tuple= ('Mark', 'Male', 55) my_tuple #Elements of a tuple my_tuple[0] my_tuple[1] my_tuple[2] #manipulating a tuple's element my_tuple[0]*10 Dicitionaries they have two major element types and value they are a collection of key value pairs Each key is seperated from its value by a colon( ![]() the items are seperated by commas and the whole thing is enclosed in a curly brace. key are unique within a dictionary. city= {0:"LA", 1:"PA", 2:"FL" } city city[0] city[1] city[2] names= {1:"David", 6:"Bill", 9:"jim"} names names[0] #different key vaues doesnt work names[1] names[2] #different key vaues doesnt work names[6] names[9] #a string can also serve as a key edu = {"David": "BSC", "Bill": "MSC", "Jim": "PHD"} edu edu [David] #will not work, need inverted comma as a string edu ["David"] #you can also change the value to keys as shown below edu ["David"] = "MSC" edu #run to confirm the values has been updated #Updating keys in dictionary #first delete the key and value element and then add new element city= {0: "LA", 1: "PA", 2: "FL"} #make key 6 as value "LA" del city[0] city city[6]= "LA" city #Fetch all keys and values seprately city.keys() city.values() edu.values() edu.keys() |
Re: Python For Data Science Bring You On Speed To Data Processing by eosho: 5:05pm On May 06, 2020 |
locust: Like I mentioned in one of my post, Anaconda is a collection of tools including IDE for python programming, when this is installed you don't need to intall python anymore.... When installed you can benefit of its Spyder IDE, jupyter notebook, etc. Also its multiplatform so you can run it on windows, Linux and apple OS of your choice 1 Like |
Re: Python For Data Science Bring You On Speed To Data Processing by eosho: 8:04pm On Jun 02, 2020 |
If-Else-For statement If statement: is used to check a condition is true, if true it moves to perform s given function #Practice 8a age=60 if age < 50: print ( "Group1" ) print ( "done with if" ) #evaluates as false 'cos age is less than 50 age=60 if age < 70: print ( "Group1" ) print ( "done with if" ) #evaluates as true 'cos age is less than 70 If_else Statement: this a statement that resolves to the else statement when the if statement isnot true. #Practice 8b age =60 if age<50: print( "Group1" ) else: print ( "Group2" ) print ( "Done with if else" ) Multiple esle if statement : Multiple else condition in if #Practice 8c marks=75 if (mark<30): print( "fail" ) elif(marks <50): print ( "Second Class" ) elif (marks <80): print ( "First Class" ) elif (marks <80): print( "Distinction" ) else: print( "Error in Marks" ) Nested if statement: #Practice 8d x = 45 if (x<50): print ( "Number is less than 50" ) if (x<40): print ("Number is lelss than 40" ) if (x<30): print ( "Number is less than 30" ) else: print ( "Number is greater than 30" ) else: print ( "Number is greater than 40" ) else: print ( "Number is greater than 50" ) # For loop """" For loop is a iteration statement It allows code block to be repated certain number of times Generally we see a for loop being iterating through a list """ syntax: for <variable> in <sequence>: <code block> #Practice 8e #Example_1 my_num = 1 for i in range(1,20): my_num= my_num +1 print("my num vslue is", my_num) #Eample 2 sumx = 0 for x in range(1,20): sumx =sumx + x print (sumx) #Eample 3 a_list = [1,5,7,9,6,8] for x in a_list: print (x*2) # Break Statement To stop execution of a loop stopping the loop in midway using condition #Practice 9 sumx = 0 for x in range (1,200): sumx =sumx + x if (sumx>500): break print(sumx) # Function """ A function is a piece oc code, which takes input values and returns a result. function can be used again with different values. instead of rewriting the whole code. it's much cleaner todefine a function, which can be used repeatedly. Function improves modularity of a program. Function are also known as Method. """ Function syntax: Function has two components: Header Body The header has two components Function Name Input Parameters Body consit of thr procedure, which we want the function to carry out #Practice 10 #Example: def square(a): c=a**a return square(15) square (10) square (3) square (4) #Test question: write a function that receives 2 variables as inputs and returns the remainder when variable 1 is divided by variable 2 def remainder ( var1, var2): a= var1%var2 print (a) |
(1) (Reply)
Advice Us Please / Programmers, Share Your Experience With Naija hackers / Programmer
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2025 Oluwaseun Osewa. All rights reserved. See How To Advertise. 40 |