byzh-core 0.0.9.4__py3-none-any.whl → 0.0.9.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- byzh/core/Brecorder/record2d.py +12 -5
- {byzh_core-0.0.9.4.dist-info → byzh_core-0.0.9.6.dist-info}/METADATA +1 -1
- {byzh_core-0.0.9.4.dist-info → byzh_core-0.0.9.6.dist-info}/RECORD +7 -7
- {byzh_core-0.0.9.4.dist-info → byzh_core-0.0.9.6.dist-info}/LICENSE +0 -0
- {byzh_core-0.0.9.4.dist-info → byzh_core-0.0.9.6.dist-info}/WHEEL +0 -0
- {byzh_core-0.0.9.4.dist-info → byzh_core-0.0.9.6.dist-info}/entry_points.txt +0 -0
- {byzh_core-0.0.9.4.dist-info → byzh_core-0.0.9.6.dist-info}/top_level.txt +0 -0
byzh/core/Brecorder/record2d.py
CHANGED
@@ -5,9 +5,10 @@ from .. import B_os
|
|
5
5
|
# from byzh.core import B_os
|
6
6
|
|
7
7
|
class B_Record2d:
|
8
|
-
def __init__(self, csv_path, mode:Literal["w", "a", "r"]="r"):
|
8
|
+
def __init__(self, csv_path, mode:Literal["w", "a", "r"]="r", title:str=None):
|
9
9
|
self.csv_path = csv_path
|
10
10
|
self.mode = mode
|
11
|
+
self.title = title
|
11
12
|
|
12
13
|
B_os.makedirs(csv_path)
|
13
14
|
self.data = pd.DataFrame()
|
@@ -19,6 +20,8 @@ class B_Record2d:
|
|
19
20
|
elif mode == "r":
|
20
21
|
self.__read()
|
21
22
|
|
23
|
+
if self.data.index.name is None:
|
24
|
+
self.data.index.name = title
|
22
25
|
# 支持 recorder[row, col] 访问
|
23
26
|
def __getitem__(self, key):
|
24
27
|
if isinstance(key, tuple) and len(key) == 2: # 读值操作
|
@@ -42,6 +45,7 @@ class B_Record2d:
|
|
42
45
|
assert type(value) == pd.Series, "仅支持 Series 赋值"
|
43
46
|
key = str(key)
|
44
47
|
self.data.loc[key, :] = value.copy()
|
48
|
+
self.__save()
|
45
49
|
|
46
50
|
# 复制一行
|
47
51
|
def copy_row(self, new_row, origin_row):
|
@@ -79,7 +83,7 @@ class B_Record2d:
|
|
79
83
|
return float(self[row, col])
|
80
84
|
|
81
85
|
def get_bool(self, row, col) -> bool:
|
82
|
-
result
|
86
|
+
result = self.get_str(row, col)
|
83
87
|
if result.lower() in ("true", "1"):
|
84
88
|
return True
|
85
89
|
elif result.lower() in ("false", "0"):
|
@@ -105,7 +109,7 @@ class B_Record2d:
|
|
105
109
|
if __name__ == '__main__':
|
106
110
|
csv_file = "test_data.csv"
|
107
111
|
|
108
|
-
recorder = B_Record2d(csv_file, mode="w")
|
112
|
+
recorder = B_Record2d(csv_file, mode="w", title='x\y')
|
109
113
|
|
110
114
|
# 用索引方式赋值
|
111
115
|
recorder["awa", "OvO"] = 10
|
@@ -113,10 +117,13 @@ if __name__ == '__main__':
|
|
113
117
|
recorder["qwq", "OvO"] = 30
|
114
118
|
recorder["qwq", "TwT"] = 40
|
115
119
|
|
116
|
-
recorder['aaa'] = recorder['
|
120
|
+
recorder['aaa'] = recorder['qwq']
|
117
121
|
|
118
122
|
print("当前内容:")
|
119
123
|
print(recorder)
|
120
124
|
|
121
125
|
# 用索引方式读取
|
122
|
-
print("awa, OvO =", recorder["awa", "OvO"])
|
126
|
+
print("awa, OvO =", recorder["awa", "OvO"])
|
127
|
+
|
128
|
+
recorder = B_Record2d(csv_file, mode="r")
|
129
|
+
print(recorder)
|
@@ -4,7 +4,7 @@ byzh/core/Barchive/__init__.py,sha256=wUdz646VS0Uhq9lwMkd3YQHCvQhLDqgADoDjFGMqIn
|
|
4
4
|
byzh/core/Barchive/archive.py,sha256=S1hy3qYFEZr5RRmx_Mnq1s2IMUEw973ny1rKSL7J_a0,6721
|
5
5
|
byzh/core/Brecorder/__init__.py,sha256=rYlgYIhr_AcPuGkZRCitbi2_hZYyoERk4XIZ14CU1dk,108
|
6
6
|
byzh/core/Brecorder/record1d.py,sha256=P7y4Gbc0zYcRsZBT4CeYgv35k0tU4h3ED-3H8RQ6cuU,2083
|
7
|
-
byzh/core/Brecorder/record2d.py,sha256=
|
7
|
+
byzh/core/Brecorder/record2d.py,sha256=lwyxV4xLzngvn_uU2mpDwqNrJzaVhosYzCOQ_QIKtnk,3824
|
8
8
|
byzh/core/Btable/__init__.py,sha256=NlQBjp_mvObEUm4y6wXbGipkNM2N3uNIUidaJkTwFsw,62
|
9
9
|
byzh/core/Btable/auto_table.py,sha256=avMeRWydw9L8s3fU0-BSl8a2dCyreIUzW--csm5eR0g,14734
|
10
10
|
byzh/core/Bterminal/__init__.py,sha256=azRLD-kY8Tv2c3llHRBrEJIdVgYw6hAoLgzJeA4PvE0,142
|
@@ -18,9 +18,9 @@ byzh/core/Butils/text_style.py,sha256=34u2-Rsur63iNQ0m7tHxpFWqnQZWybSxBx7vnhOhqD
|
|
18
18
|
byzh/core/Butils/timer.py,sha256=OLxbWWRauYjp1KwavACjoyrqrCciUiIG2ae7qgtZrVA,511
|
19
19
|
byzh/core/Bwriter/__init__.py,sha256=QcHzKs0305Pr78ZvZgcC_4miSYZh8jJQDt5TD0GIeEg,82
|
20
20
|
byzh/core/Bwriter/writer.py,sha256=ss9EWo-l7czBUlY7Fu0buvQgO5fRspYKtC2X6eaRa0c,3213
|
21
|
-
byzh_core-0.0.9.
|
22
|
-
byzh_core-0.0.9.
|
23
|
-
byzh_core-0.0.9.
|
24
|
-
byzh_core-0.0.9.
|
25
|
-
byzh_core-0.0.9.
|
26
|
-
byzh_core-0.0.9.
|
21
|
+
byzh_core-0.0.9.6.dist-info/LICENSE,sha256=-nRwf0Xga4AX5bsWBXXflpDpgX_U23X06oAMcdf0dSY,1089
|
22
|
+
byzh_core-0.0.9.6.dist-info/METADATA,sha256=fy-f7A_R_q_4EaNaSoy9niihIjZ-iLhERf3r_XLVqhU,371
|
23
|
+
byzh_core-0.0.9.6.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
24
|
+
byzh_core-0.0.9.6.dist-info/entry_points.txt,sha256=qoN3Uvulj0BcOQVDqsFqP2dBVQzG1QrUtC5wFsghSLo,51
|
25
|
+
byzh_core-0.0.9.6.dist-info/top_level.txt,sha256=tmaFVY8uApe6apOETSOgwz-4v5Mj4uxgRT8yNnDNZNA,5
|
26
|
+
byzh_core-0.0.9.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|