擅长:python、mysql、java
<p>你快到了!
将数据作为列表读取后,您可以将列表分成5个部分,然后将其传递到<code>pd.DataFrame()</code></p>
<pre class="lang-py prettyprint-override"><code>with open('data.txt','r') as file:
data = file.read().split('\n')
# split the list in chunks of 5s
chunks = [data[x:x+5] for x in range(0, len(data), 5)]
# pass the chunks in pd.DataFrame and specify the columns names of the OP:
pd.DataFrame(chunks, columns=["Column1", "Column2", "Column3", "Column4", "Column5"])
</code></pre>
<p>另外,我假设最后一列中有一个拼写错误,因为它似乎再次命名为Column4,但在这里我将其命名为Column5。如果这是您需要的,您可以随时将其命名为Column4</p>