-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpandas_function.py
More file actions
39 lines (30 loc) · 922 Bytes
/
Copy pathpandas_function.py
File metadata and controls
39 lines (30 loc) · 922 Bytes
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
import pandas as pd
1# automatic car
df=pd.read_csv("volvo_car.csv")
filtered_df = df[
(df["transmission"] == "Automatic")
]
# Print full filtered result
print(filtered_df)
# # Print only the 'trnsmissionl' column
print(filtered_df["transmission"])
2# Filtering: Automatic + Petrol
filtered_df = df[
(df["transmission"] == "Automatic") &
(df["energy_consumption__fuel"] == "Petrol")
]
print(filtered_df)
3# Filtering: hybrid car
filtered_df = df[df["energy_consumption__fuel"] == "Hybrid - Petrol"]
print(filtered_df)
print(filtered_df["energy_consumption__fuel"])
4# Filtering: price 20000–30000 ke beech
filtered_df=df[(df["price_eur"] >= 20000) & (df["price_eur"] <= 30000)]
print(filtered_df)
print(filtered_df["price_eur"])
5# Filtering: model and title
filtered_df = df[
(df["technical_specifications__engine_capacity"] == "1969") &
(df["title"] == "Volvo XC60")
]
print(filtered_df)