擅长:python、mysql、java
<p>您可以最容易地操纵这些值,而不是作为一个整体操纵数据帧</p>
<p>假设您的数据是:</p>
<pre><code>import pandas as pd
# Example data
df = pd.DataFrame([["sample 1", "Unnamed:1", "sample 2", "Unnamed:2"], [0.614, "transmission 1", 0.68168, "transmission 2"]])
</code></pre>
<div class="s-table-container">
^{tb1}$
</div>
<p>现在,让我们保留所需的值及其列标题</p>
<pre><code>vals = df.values
new_df = pd.DataFrame(vals[1,::2], index= vals[0, ::2], columns=["wavelength")
</code></pre>
<p>现在新的_df是:</p>
<div class="s-table-container">
^{tb2}$
</div>