import csv
import pandas as pd
def fun(name='text.csv'):
file = open(name, 'rb')
_input = pd.read_csv(file, header=None)
_output = pd.DataFrame()
for index, i in _input.iterrows():
main_series = i[:3]
for j in range(0, 8):
sub_series = (i[3 + 5 * j:8 + 5 * j])
print((main_series.append(sub_series)).reset_index())
#_output=_output.append((main_series.append(sub_series)).reset_index(),ignore_index=True)
_output.to_csv('upadated_' + name)
break
fun()
在此代码中 当我使用reset_index附加带有main_series的子系列时,我正在获取数据帧。 但是如何获得系列呢?
index 0
0 0 A002
1 1 R051
2 2 02-00-00
3 3 04-30-11
4 4 00:00:00
5 5 REGULAR
6 6 3143506
7 7 1087907