The most common and widely used feature of python programming for data science is methods. You will see the usage of methods quite often while you dive further into data science with python.
Lets go ahead and create a string :
In : s=' hello! Welcome To Python Crash Course' In : s.lower() Out: 'hello! welcome to python crash course'
It’s so simple isn’t it ? The lower method on a string will convert all the characters to lower case. You can try the s.upper() method and see if the method changes your string to upper case. There are several methods of a string which can be found by pressing tab in jupyter notebook after the dot symbol ( s. ), you can try out various methods available.
Lets go over the split method.
In : s.split() Out: ['hello!', 'Welcome', 'To', 'Python', 'Crash', 'Course']
The split functions splits the strings on the white space. If you need to split the dataset based out of ‘!’ then you can pass the ! mark within quotes and within the split function. The method will split the string where it finds the ! mark.
In : s.split('!') Out: ['hello', 'Welcome To Python Crash Course']
You can try and use methods on strings, dictionaries and lists. Lets try a method on a list.
In : list=[1,2,3] In : list.pop() Out: 3
The pop method removes the last component/element from the list permanently. If there is a need to pop a particular item of your choice, you have to target the items index and pass the value within the pop functional brackets.
In : list Out: [1,2]
Here we come to an end of the python crash course for data science. These 12 modules / blog posts should help any beginner ( like me ) to gain fair bit of knowledge on python as we move along more complex codes within data science.
Leave a comment if you really enjoyed this crash course series.