我有一个很大的CSV文件。在csv文件中有几个标题如下。
"Level and Distortion",,,,,,,,,,,,,,,
"Ch1 (F)",,"Ch1 (H2)",,"Ch1 (H3)",,"Ch1 (Total)",,"Ch2 (F)",,"Ch2 (H2)",,"Ch2 (H3)",,"Ch2 (Total)",
X,Y,X,Y,X,Y,X,Y,X,Y,X,Y,X,Y,X,Y
Hz,Vrms,Hz,Vrms,Hz,Vrms,Hz,Vrms,Hz,Vrms,Hz,Vrms,Hz,Vrms,Hz,Vrms
20,0.00772013164376534,20,5.60982648239952E-05,20,0.000389709733151927,20,0.011492581958802,20,0.00699792689186063,20,0.000151471712877565,20,0.000389940899485093,20,0.010080448380793
21.1179638886716,0.00747175133180212,21.1179638886716,8.83327496082501E-05,21.1179638886716,0.000426696028852445,21.1179638886716,0.0122462876404656,21.1179638886716,0.00756340531214287,21.1179638886716,0.000181697169530165,21.1179638886716,0.000443499862648762,21.1179638886716,0.0108494276048029
"THD Ratio",,,,,,,,,,,,,,,
Ch1,,Ch2,,,,,,,,,,,,,
X,Y,X,Y,,,,,,,,,,,,
Hz,%,Hz,%,,,,,,,,,,,,
20,83.009797319554,20,82.1460991930652,,,,,,,,,,,,
21.1179638886716,85.3656629417084,21.1179638886716,82.0338466400102,,,,,,,,,,,,
22.2984199401618,90.6674826441566,22.2984199401618,85.7190774666039,,,,,,,,,,,,
"Reference Waveform",,,,,,,,,,,,,,,
Ch1,,Ch2,,,,,,,,,,,,,
X,Y,X,Y,,,,,,,,,,,,
s,V,s,V,,,,,,,,,,,,
0,0,0,0,,,,,,,,,,,,
2.08333333333333E-05,6.47890208369956E-08,2.08333333333333E-05,6.47890208369956E-08,,,,,,,,,,,,
4.16666666666667E-05,5.18304721721536E-07,4.16666666666667E-05,5.18304721721536E-07,,,,,,,,,,,,
6.25E-05,1.74923655865586E-06,6.25E-05,1.74923655865586E-06,,,,,,,,,,,,
Level and Distortion
、THD Ratio
和Reference Waveform
是我喜欢分开的测量类型。我必须在上面的csv中分离一些标题。例如,当我调用变量a时,它显示Levels and Distortion dataframe及其数据,如果我们调用变量b,它显示THD ratio dataframe及其数据。有谁知道怎么把它们分开。
dataframe如下所示。
并且也适用于THD ratio
和Reference Waveform
。
1条答案
按热度按时间gojuced71#
假设总是有三个标题行,上面将是dataframe的标题(在第一列中),然后是后面的值-并且您知道标题的名称-您可以使用以下内容:
globals()
可用于查找所有已定义的变量,globals()["a"] = 1
将定义一个变量a = 1
。建议不要使用它,而是显式地定义所有内容,但如果你真的不想使用字典,那么这就是你设置变量的方式。如果标题事先不知道,并且如果标题行的第一列之后的所有列始终为“NA”,则可以使用以下命令查找标题: