I have a pandas data frame it looks like this
0 1 2 3 4 5 6 7 8 9 ... 253 254 255 256 257 258 259 260 261 262
0 30 84 126 135 137 179 242 342 426 ... 0 0 0 0 0 0 0 0 0 0
1 24 53 75 134 158 192 194 211 213 ... 0 0 0 0 0 0 0 0 0 0
2 51 143 173 257 446 491 504 510 559 ... 0 0 0 0 0 0 0 0 0 0
3 1 20 22 92 124 149 211 335 387 ... 0 0 0 0 0 0 0 0 0 0
4 34 51 56 106 110 121 163 233 266 ... 0 0 0 0 0 0 0 0 0 0
I want to divide each number in the data frame by 7 and put the result in the data frame instead of the number, I was testing with a for loop, but it doesn't work for me
for i in x:
y = i % 7
if y == 0:
x.replace(i, 7)
It should work but when I print the data frame I can't see the change, I even tried to replace a specific value, but also no change.
How should I do it and I was wondering what is the best solution memory wise since I'm trying to scale this to a bigger data frame
lets say we have a line like this
0 8 30 28 36 40 45 0 56
the output I want should be,
0 1 2 7 1 5 3 0 7
Thanks in advance