Код: Выделить всё
Column1 Column2
0 10001 252207
1 100018 219559
2 100068 251102
3 100089 107320
4 100111 250975
5 100111 28540
6 100112 252253
7 100157 17883
. ... ...
10000 100998 1231233
Код: Выделить всё
Column1 Column2'
0 t # 0 NULL
1 10001 252207
2 t # 1 NULL
3 100018 219559
4 t # 2 NULL
5 100088 251102
6 100088 107320
7 t # 3 NULL
8 100111 250975
9 100111 28540
10 t # 4 NULL
11 100112 252253
12 t # 5 NULL
13 100157 17883
... ... ...
end-3 t # {int} NULL
end-2 100998 1231233
end-1 100998 3333
end 100998 4123
Код: Выделить всё
with open("week-1-algorithm.txt", "r") as f:
text = [line.split() for line in f]
df = pandas.DataFrame(
text,
columns=["Column1", "Column2"],
)
new_df = df["Column1"].copy()
iteration_number = 0
for i in range(len(new_df)):
if (new_df[i] != new_df[i+1]):
new_df.loc[i+1]= f't # {j}'
iteration_number += 1
Подробнее здесь: https://stackoverflow.com/questions/785 ... data-frame