Path: blob/master/Gen AI for Intelligent Data Handling/1.1Data Manipulation using Pandas.ipynb
3370 views
Kernel: Python 3 (ipykernel)
Data Manipulation using Pandas
Series: 1D () , 1,2,3
DataFrame: 2D(), R*C [[1,2]],[[2,2]]
Panels: 3D(), ARC , [[[1,2]],[[3,2,]],[[2,3]]
Python Containers
Number (Int, Float)
Str "A" , "Aashi" ,"1234abc" , "This my class" , "hh hh "hhh"
Tuples = (1,2,3,3) , (4,5,6)
List = [1,2,36] , [2,"A"] , append, insert (2,4)
Dic = {"A" : 1, "B:"2}
In [7]:
Out[7]:
[1, 2, 3]
In [8]:
Out[8]:
one 1
two 2
three 3
dtype: int64
In [9]:
Out[9]:
In [10]:
Out[10]:
In [11]:
Out[11]:
In [12]:
Out[12]:
1.Rows from top
In [13]:
Out[13]:
Rows from bottom
In [14]:
Out[14]:
3. Info of DataFrame 1:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5 entries, 0 to 4
Data columns (total 3 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Name 5 non-null object
1 Age 5 non-null int64
2 Department 5 non-null object
dtypes: int64(1), object(2)
memory usage: 252.0+ bytes
In [16]:
Out[16]:
In [15]:
Out[15]:
In [17]:
Out[17]:
4. Description of DataFrame 2:
In [18]:
Out[18]:
5. Shape of DataFrame 1:
(5, 3)
In [19]:
Out[19]:
6. Columns of DataFrame 2:
Index(['Name', 'Salary', 'Experience'], dtype='object')
In [20]:
Out[20]:
In [21]:
Out[21]:
0 25
1 30
2 35
3 28
4 32
Name: Age, dtype: int64
In [22]:
Out[22]:
0 25
1 30
2 35
3 28
4 32
Name: Age, dtype: int64
In [23]:
Out[23]:
0 25
1 30
2 35
3 28
4 32
Name: Age, dtype: int64
In [24]:
Out[24]:
pandas.core.series.Series
In [25]:
Out[25]:
8. Selecting row labeled 'Bob' in DataFrame 2:
Name Salary Experience
2 Bob 55000 8
In [ ]:
In [26]:
Out[26]:
In [27]:
Out[27]:
In [33]:
Out[33]:
In [34]:
Out[34]:
Name 0
Age 0
Department 0
Salary 1
Experience 1
dtype: int64
In [36]:
In [37]:
Out[37]:
10. Filling missing values in DataFrame with median:
In [39]:
Out[39]:
In [41]:
Out[41]:
11. Grouping DataFrame 3 by 'Department':
Department: Analytics
Name Age Department Salary Experience
4 Ashi 32 Analytics 56500.0 10.0
Department: Finance
Name Age Department Salary Experience
1 Alice 30 Finance 60000.0 5.0
Department: HR
Name Age Department Salary Experience
0 John 25 HR 50000.0 3.0
Department: IT
Name Age Department Salary Experience
2 Bob 35 IT 55000.0 8.0
3 Emma 28 IT 58000.0 4.0
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
Partcipants with Age Greater than 30
In [ ]:
In [ ]:
In [ ]: