22 Dec How to Install Pandas on Windows
To install Pandas on Windows, we need Python and pip. The pip is used to download and install Python packages. Let us first download and install Python and pip.
After installing Python and pip, open CMD and use pip to install Pandas. Type the following command and press Enter:
1 2 3 |
pip install pandas |
The above will install pandas on Windows. You can also use any of the following Python Distributions/ Platforms to run your first Pandas program:
Run the first Pandas program
Now, let us run our first Pandas program. In the sample program, we need to first import the Pandas after installing:
1 2 3 |
import pandas |
To avoid writing pandas, again and again, we can also use an alias i.e.
1 2 3 |
import pandas as pd |
Let us now see the following Pandas code which can be run in any of the Python Distributions. Do notice that we have imported pandas at the top:
1 2 3 4 5 6 7 8 9 10 11 12 |
import pandas as pd data = { 'student': ["Amit", "John", "Jacob", "David", "Steve"], 'rank': [1, 4, 3, 5, 2] } res = pd.DataFrame(data) print("Student Records\n\n",res) |
Output
1 2 3 4 5 6 7 8 9 10 |
Student Records student rank 0 Amit 1 1 John 4 2 Jacob 3 3 David 5 4 Steve 2 |
In the above program, we have created a dataset and added it to the DataFrame() method. To understand, what is DataFrame and its purpose, let us see the next lesson. The 0, 1, 2, etc. are the index that gets automatically added to the table.
If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.
For Videos, Join Our YouTube Channel: Join Now
Read More:
No Comments