-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.py
29 lines (20 loc) · 997 Bytes
/
data.py
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
import pandas as pd # type: ignore
from datetime import timedelta
from args import parse_arguments
from lightroom import FIELD_NAMES_LIST, LightroomDB
def get_filtered_images():
args = parse_arguments()
lightroom_db = LightroomDB(args.catalog_path)
results = lightroom_db.get_all_images(args.picks_only)
selected_data = [{key: item[key] for key in FIELD_NAMES_LIST} for item in results]
data = pd.DataFrame(selected_data)
# Convert the "captureTime" column to datetime type
data["captureTime"] = pd.to_datetime(data["captureTime"], format="mixed")
# Calculate the date one year ago based on the lookback argument
start_date = data["captureTime"].max() - timedelta(days=args.lookback)
# Filter out images taken in the last year and exclude iPhone camera usage
filtered_data = data[
(data["captureTime"] > start_date)
& (~data["cameraName"].str.contains("iPhone", case=False, na=False))
]
return filtered_data