Posts

Showing posts from 2016

Numpy: How to do data analysis using python?

Image
In my last post, we discussed " How to use lists, arrays, Numpy to make life easy with Python? ". If you are beginner go to the first post of this blog.  In this post, I will discuss how data can be analysed in python?. Sometimes we have a huge number of data files and we want to take averages over some specific contents of files or want to read only some specific rows and columns. This post is not the first post about data analysis, there are many excellent bloggers and websites who have tried to explain in multiple ways how data should be analysed using python!  My aim is to bring multiple techniques together to make it is easy to use for the reader. When I started learning python, I found all the information on the internet, but I did not know how to use the information. It was very easy to do a statistical analysis of one file (python makes it one second go), but I did not know how to combine multiple files and then analyse only specific data from these files.

How to use lists, arrays, Numpy to make life easy with Python?-Part 1

Image
 In my last post ( How to define a function in python? )  we learnt use of the functions in python. All what we learnt is useful for many things but if you are interested to solve mathematical problems using python, you need to know more. The same is true if you have huge databases to analyse. Today we will learn about how do you read and write data using python. This is time to get to know Numpy. I am trying to introduce minimum concepts for the beginners. I will do another blog for advanced python in the future. In the advance part we will see "how Numpy can be used to increase efficiency of python code?".   What is Numpy? I would just like to quote how Numpy is described on their official webpage . NumPy is the fundamental package for scientific computing with Python. It contains among other things: a powerful N-dimensional array object sophisticated (broadcasting) functions tools for integrating C/C++ and Fortran code useful linear algebra, Fourier trans

How to define a function in python?

Image
Use of a function in Python We have learnt few things in our last two posts about python. We started from the  beginning with a python prgoram  and continued with  how to write a for loop in python ?  In this post I will discuss how to write and call a simple function in python. So let us start with simplest function. Start a python notebook as explained in my last posts or if you want to use terminal script then open any text editor and paste the following code. You can also run these codes on my blog at the end of each post. def age (x):       return "Your age is" , x      We defined a very simple function called age(x). This function just prints the value given to it. Let us check how to call it. In [16]: age(20) Out [20]: Your age is 20 We gave input 20 to the function and it printed " Your age is 20 ". Let us now go a level higher and try to write another function. def square (x):    f=x*x      return In [22]: squar

Writing a loop first time in python

Image
In the last post ( Beginning with a python program: The tail ) we started from scratch how to begin with python. In this post we will advance towards writing a for loop. Before we can start that, let us understand the structure of the program. We need to know how python would differentiate between string (text), integer (whole number), float (real number) etc. Python is beautiful because it has built-in types. Let us try to understand these types. Ipython Notebook We say that you can run python directly from terminal or command-line environment or by saving a text file as file.py and run it as python file.py in terminal. But there is another way to run and edit scripts at the same time. This is called Ipython notebook. In linux just install ipython look at how to install ipython on linux? . If you have installed anaconda which I would suggest for windows users very strongly then just look at  how to run ipython notebook on windows?  Once you know it just type in anaconda or

Beginning with a python program: The tail

Image
The beginning  This blog is thought for the people who want to start to learn python programming . We start with the tail because a python can swallow you if you go untrained towards the tongue. Once we will be familiar with the python, I will discuss advanced computational libraries like Numpy, Scipy, Pandas, Glob  and hybrid coding by mixing other programming languages with python. Why Python? There are many programming languages which one can use. Python is good because it is simple. It uses  simple syntax compared to many other programming languages. The code is short and can be understood easily. There are though questions, if python is good for high-performance computing (the tongue) ?  There are ways to make python efficient even for those cases. Anyway here we do not want to talk about efficiency as we are learning simple programming (the tail). In few words, python is good because: It is easy to learn. Syntax is simple. It is flexible in use It is free. I