-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataFrameOperations.py
More file actions
49 lines (41 loc) · 1.37 KB
/
dataFrameOperations.py
File metadata and controls
49 lines (41 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import pandas as pd
import numpy as np
# ------------------------
# Creating Empty DataFrame
# ------------------------
df = pd.DataFrame()
print(df)
print('----------------------------------')
# ----------------------------
# Creating DataFrame From Lists
# ----------------------------
print('Creating DataFrame From Lists')
print('----------------------------------')
df = pd.DataFrame(data =[['Employee1', 1000],['Employee2', 2000],['Employee3', 4000]],
columns=['Name', 'Salary'])
print(df)
print('----------------------------------')
# ----------------------------------
# Creating DataFrame From Dictionary
# ----------------------------------
print('Creating DataFrame From Dictionary')
print('----------------------------------')
data = {'Name': ['Employee1','Employee2', 'Employee3'], 'Salary':[1000, 2000, 3000]}
df = pd.DataFrame(data)
print(df)
print('----------------------------------')
# -------------------
# DataFrame
# -------------------
print('Describe DataFrame')
print('----------------------------------')
print(df.describe())
print('----------------------------------')
print('head function DataFrame')
print('----------------------------------')
print(df.head(1))
print('----------------------------------')
print('tail function DataFrame')
print('----------------------------------')
print(df.tail(1))
print('----------------------------------')