This is Pandas Tutorial Part 1. pandas is an open source, BSD-licensed library providing high-performance, easy-to-use data structures and data analysis tools for the Python programming language.
![]() |
Creating Our First Pandas Data Frame | Pandas Tutorial Part 1 |
Today’ Topic: We create Data Frame for pandas.
Without DataFrame we can’t assess our data. Without DataFrame we can’t load your data in RAM easily.
Without pandas, we can load data in RAM, but this is not easy prose.
Open your Jupyter Notebook.
Import pandas and numpy
Import pandas as pd
Import numpy as np
import pandas and numpy |
Create Empty DataFrame:
df = pd.DataFrame()
df
Output
Empty DataFrame
Columns: []
Index: []
Empty DataFrame |
Logic: We create an empty data frame. We need to create an empty in projects, because, we can store data in the empty data frame and append this stored data. Moreover, for dynamically data append for uses.
Create a DataFrame:
df1=pd.DataFrame([[1,2,3,4],[5,6,7,8],[9,10,23,123],[23,235,123,634],[12,23,42,11]])
df1
Output:
0
|
1
|
2
|
3
|
|
0
|
1
|
2
|
3
|
4
|
1
|
5
|
6
|
7
|
8
|
2
|
9
|
10
|
23
|
123
|
3
|
23
|
235
|
123
|
634
|
4
|
12
|
23
|
42
|
11
|
Create DataFrame |
Logic: Jupyter is very smart it arrange the data in rows and columns.
Print First Three Rows:
df1.head(3)
Output
0
|
1
|
2
|
3
|
|
0
|
1
|
2
|
3
|
4
|
1
|
5
|
6
|
7
|
8
|
2
|
9
|
10
|
23
|
123
|
Print 1st 3 Rows |
Logic: df1.head(3), this means we print 1st 3 rows.
Print last 4 rows
df1.tail(4)
Output
0
|
1
|
2
|
3
|
|
1
|
5
|
6
|
7
|
8
|
2
|
9
|
10
|
23
|
123
|
3
|
23
|
235
|
123
|
634
|
4
|
12
|
23
|
42
|
11
|
Print last 4 rows |
Logic: df1.tail(4), this means we print last 4 rows.
If you have any quarry, please comment below.
0 comments:
Post a Comment