byzh-core 0.0.9.2__py3-none-any.whl → 0.0.9.3__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.
@@ -1,7 +1,8 @@
1
1
  import pandas as pd
2
2
  from typing import Literal
3
3
 
4
- from .. import B_os
4
+ # from .. import B_os
5
+ from byzh.core import B_os
5
6
 
6
7
  class B_Record2d:
7
8
  def __init__(self, csv_path, mode:Literal["w", "a"]="w"):
@@ -17,16 +18,38 @@ class B_Record2d:
17
18
 
18
19
  # 支持 recorder[row, col] 访问
19
20
  def __getitem__(self, key):
20
- row, col = key
21
- row, col = str(row), str(col)
22
- return self.data.loc[row, col]
21
+ if isinstance(key, tuple) and len(key) == 2: # 读值操作
22
+ row, col = key
23
+ row, col = str(row), str(col)
24
+ return self.data.loc[row, col]
25
+ if isinstance(key, str): # 读行操作
26
+ row = str(key)
27
+ return self.data.loc[row, :]
23
28
 
24
29
  # 支持 recorder[row, col] = value
25
30
  def __setitem__(self, key, value):
26
- row, col = key
27
- row, col, value = str(row), str(col), str(value)
28
- self.data.loc[row, col] = value
31
+ if isinstance(key, tuple) and len(key) == 2: # 赋值操作
32
+ row, col = key
33
+ row, col, value = str(row), str(col), str(value)
34
+ self.data.loc[row, col] = value
35
+ self.__save()
36
+ if isinstance(key, str): # 赋值行操作
37
+ assert type(value) == pd.Series, "仅支持 Series 赋值"
38
+ key = str(key)
39
+ self.data.loc[key, :] = value.copy()
40
+
41
+ # 复制一行
42
+ def copy_row(self, new_row, origin_row):
43
+ new_row, origin_row = str(new_row), str(origin_row)
44
+
45
+ if origin_row not in self.data.index:
46
+ raise KeyError(f"源行 {origin_row} 不存在")
47
+
48
+ # 深拷贝一份行数据
49
+ self.data.loc[new_row] = self.data.loc[origin_row].copy()
50
+
29
51
  self.__save()
52
+ return self
30
53
 
31
54
  # 转置
32
55
  def T(self):
@@ -85,6 +108,8 @@ if __name__ == '__main__':
85
108
  recorder["qwq", "OvO"] = 30
86
109
  recorder["qwq", "TwT"] = 40
87
110
 
111
+ recorder['aaa'] = recorder['qwwq']
112
+
88
113
  print("当前内容:")
89
114
  print(recorder)
90
115
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: byzh-core
3
- Version: 0.0.9.2
3
+ Version: 0.0.9.3
4
4
  Summary: byzh-core是byzh系列的核心库,包含了一些常用的工具函数和类。
5
5
  Author: byzh_rc
6
6
  License: MIT
@@ -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=7JlM9VQnKNV6qGpC6cXZ5gdEROFeDCO840Gq6Y4dciw,2481
7
+ byzh/core/Brecorder/record2d.py,sha256=MRVnPXj4nZMyFm_5kZ0PyjQjO5kWiKQd1L4yV0TKWb8,3431
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.2.dist-info/LICENSE,sha256=-nRwf0Xga4AX5bsWBXXflpDpgX_U23X06oAMcdf0dSY,1089
22
- byzh_core-0.0.9.2.dist-info/METADATA,sha256=vyEpFvofVI_8b5BgXNHgjxLLNTO8G3gC6q-BAX9gAt4,371
23
- byzh_core-0.0.9.2.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
24
- byzh_core-0.0.9.2.dist-info/entry_points.txt,sha256=qoN3Uvulj0BcOQVDqsFqP2dBVQzG1QrUtC5wFsghSLo,51
25
- byzh_core-0.0.9.2.dist-info/top_level.txt,sha256=tmaFVY8uApe6apOETSOgwz-4v5Mj4uxgRT8yNnDNZNA,5
26
- byzh_core-0.0.9.2.dist-info/RECORD,,
21
+ byzh_core-0.0.9.3.dist-info/LICENSE,sha256=-nRwf0Xga4AX5bsWBXXflpDpgX_U23X06oAMcdf0dSY,1089
22
+ byzh_core-0.0.9.3.dist-info/METADATA,sha256=rqL_ag27Elyre_60ytrzhGJ7EKSQ3P2IpMyk5i-6n1Q,371
23
+ byzh_core-0.0.9.3.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
24
+ byzh_core-0.0.9.3.dist-info/entry_points.txt,sha256=qoN3Uvulj0BcOQVDqsFqP2dBVQzG1QrUtC5wFsghSLo,51
25
+ byzh_core-0.0.9.3.dist-info/top_level.txt,sha256=tmaFVY8uApe6apOETSOgwz-4v5Mj4uxgRT8yNnDNZNA,5
26
+ byzh_core-0.0.9.3.dist-info/RECORD,,