I have below code
I am trying to insert new columns as specific positions with insert method. Below is my code,
import pandas as pd
(pd.DataFrame({'product name': ['laptop', 'printer', 'printer',], 'price': [1200, 150, 1200], 'price1': [1200, 150, 1200]})
.insert(0, 'AAA', -1)
.insert(1, 'BBB', -2)
)
With this I am getting below error,
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'insert'
>>>
Could you please help to resolve this error.
Any pointer is highly appreciated.