-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessing_csv_data.py
More file actions
51 lines (38 loc) · 1.13 KB
/
processing_csv_data.py
File metadata and controls
51 lines (38 loc) · 1.13 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
46
47
48
49
# import os
# print(os.getcwd())
# Reading a input.csv file
import pandas as pd
data = pd.read_csv('files/input.csv')
print (data)
# Reading Specific Rows
# Reading First 5 rows for the column named salary
import pandas as pd
data = pd.read_csv('files/input.csv')
# Slice the result for first 5 rows
print(data[0:5]['salary'])
print("\n")
# Reading the the first five rows for 'name' and 'dept' columns
import pandas as pd
# Read the CSV file into a DataFrame
data = pd.read_csv("files/input.csv")
selected_data = data.loc[0:4, ['name', 'dept']]
# Print the selected data
print(selected_data)
print("\n")
# Reading Specific Columns
import pandas as pd
data = pd.read_csv('files/input.csv')
# Use the multi-axes indexing funtion
print (data.loc[:,['salary','name']])
print("\n")
# Reading Specific Columns and Rows
import pandas as pd
data = pd.read_csv('files/input.csv')
# Use the multi-axes indexing funtion
print(data.loc[[1,3,5], ['salary','name']])
print("\n")
# Reading Specific Columns for a Range of Rows
import pandas as pd
data = pd.read_csv('files/input.csv')
# Use the multi-axes indexing funtion
print(data.loc[2:6,['salary','name']])