I need to calculate the B columns and I wanted to do that using a for loop. It's calculation is a a static column (Col2) multiplied by the previous column (A) while also adding in the B column. Intended Results
for i in range(df.shape[1], 3, -1):
bcol = (df['Col2']*df.iloc[:,i]).round(decimals=1)
df.insert(i, 'B', bcol, allow_duplicates=True)
Error I get: "single positional indexer is out-of-bounds
df.shape[1]is 9, theniwill start at 9, but the valid indexes are only 0 through 8. Add a-1there. - Tim RobertsRead this- Gerhard