Issue with range in loc[]
When I am giving loc[:,1:14] it throws an error
"TypeError: cannot do slice indexing on <class 'pandas.core.indexes.base.Index'> with these indexers [1] of <class 'int'>"
But loc[:,[1,2,3]] is working.
Can you please help me with it?
1 answers ( 0 marked as helpful)
Hey Shrinidhi,
A general rule to remember is the number of squared brackets on each side should match the number of dimensions the object has. Hence, if it's just a vector of data (like an array that is part of a series), you can use [ : ], but if it' more like a matrix (2-D), then you need double squared brackets [[ : ]].
Best,
365 Vik