By the way, `df[20:50,:]` is *not* a subset of `df`, but a *copy* of a 
subset of `df`.
Since `df` doesn't have any column whose name is "row", how could you 
expect the "row" to be an index.



On Monday, August 24, 2015 at 6:28:30 PM UTC+2, Robert Smith wrote:
>
> In my opinion, when you did `df[20:50,:]`, you constructed a new 
>> DataFrame, which had no longer anything to do with the original `df`. So 
>> you cannot expect it to know the original position in `df`. And when you 
>> print it, the row number (instead of index) is generated on the fly, just 
>> let you know which value is at which line of the output.
>>
>> I think what needed here is just a formatted `print()` for DataFrame, 
>> which can toggle the row number index.
>>
>
> When I do `df[20:50,:]`, the result is a subset of the original DataFrame 
> `df`, so I should expect to keep track of the index in `df`. It doesn't 
> take much to see why that is useful (an index often refers to a person, 
> geographical entity, discrete period of time, etc).
>

Reply via email to