-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeWidget.py
More file actions
79 lines (65 loc) · 2.92 KB
/
Copy pathTreeWidget.py
File metadata and controls
79 lines (65 loc) · 2.92 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import sys
import pandas as pd
import numpy as np
import os
from PySide6.QtWidgets import QApplication, QMainWindow, QTreeWidget,QTreeWidgetItem
from PySide6.QtGui import QStandardItemModel,QStandardItem, QFont, QColor
from PySide6.QtCore import Qt
from util.data_manipulation import DataManipulator
from threading import Thread
class TreeUtil():
def __init__(self, tree, selected_df):
self.tree = tree
self.selected_df = selected_df
self.checked_items_list = []
self.data_manipulator = DataManipulator
def checked_items(self):
checked_items = []
def recurse(parent_item):
for i in range(parent_item.childCount()):
child = parent_item.child(i)
grand_children = child.childCount()
if grand_children > 0:
recurse(child)
else:
if child.checkState(0) == Qt.Checked:
checked_items.append(child)
self.checked_items_list = checked_items
recurse(self.tree.invisibleRootItem())
survey_combined = pd.concat([item.model.data_frame for item in checked_items], ignore_index=True)
self.selected_df = survey_combined
#print("survey combined")
#print(survey_combined)
#print(survey_combined.shape)
#print(" ")
def ffill_outlier(self, max_mag, min_mag, max_long, min_long, max_lat, min_lat):
for item in self.checked_items_list:
self.data_manipulator.ffill_outlier_from_df(
item.model.data_frame,max_mag, min_mag, max_long, min_long, max_lat, min_lat)
self.checked_items()
def dropna_outlier(self, max_mag, min_mag, max_long, min_long, max_lat, min_lat):
for item in self.checked_items_list:
self.data_manipulator.dropna_outlier_from_df(
item.model.data_frame,max_mag, min_mag, max_long, min_long, max_lat, min_lat)
self.checked_items()
def drop_from_lasso_select(self, selected_points):
for item in self.checked_items_list:
thread = Thread(target=self.data_manipulator.drop_from_lasso_select,
args=(item.model.data_frame,
selected_points))
thread.start()
def drop_from_span_select(self,xmin,xmax):
for item in self.checked_items_list:
thread = Thread(target=self.data_manipulator.drop_from_span_select,
args=(item.model.data_frame,
xmin,
xmax))
thread.start()
def write_surveys_to_csv(self):
self.checked_items()
print("EXPORT")
output_dir = "processed_CV13_01"
os.makedirs(output_dir, exist_ok=True)
for item in self.checked_items_list:
filename = os.path.join(output_dir, item.text(0))
item.model.data_frame.to_csv(filename, index=False)