opvalue_time.columns = opvalue_time.rename(lambda x: "Vol_" + x for x in range(4,80,1))
i already have a dataset with 80 columns , need to update the column headers as Vol_4, ....Vol_80. Currently the columns are 0(no headers)
I don't think the rename method can directly process a generator expression. Instead, you can use a dictionary comprehension to create a mapping of old column names to new ones, or directly assign a new list of column names to opvalue_time.columns. You could try this instead:
opvalue_time.columns = ["Vol_" + str(x) for x in range(4, 80)]
This assumes your DataFrame initially has 76 columns, matching the range specified (you may need to adjust the range as necessary)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With