[英]How to create ordered numbers?
I want to create two columns (row, column) in a data frame that contains ordered numbers based on the value.我想在包含基于值的有序数字的数据框中创建两列(行、列)。 For example the value is 128, Something like that:例如值是 128,类似这样的东西:
so the number of rows will be 128 * 128, if 256 then 256*256 and so on所以行数将为 128 * 128,如果为 256,则为 256 * 256,依此类推
You can use a nested for loop:您可以使用嵌套的 for 循环:
x,y = [],[]
for i in range(1,129):
for j in range(1,129):
x.append(j)
y.append(i)
df = pd.DataFrame({'x':x, 'y':y})
Result:结果:
x y
0 1 1
1 2 1
2 3 1
3 4 1
4 5 1
... ... ...
16379 124 128
16380 125 128
16381 126 128
16382 127 128
16383 128 128
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.