About 6,030,000 results
Open links in new tab
  1. slice - How slicing in Python works - Stack Overflow

    The colon, :, is what tells Python you're giving it a slice and not a regular index. That's why the idiomatic way of making a shallow copy of lists in Python 2 is

  2. What does the slice() function do in Python? - Stack Overflow

    Jul 19, 2015 · Whenever some other code uses slice notation on your an instance of your class Python will call your __getitem__ method with a slice object. (Older versions of Python used a __getslice__ …

  3. How to slice a list from an element n to the end in Python?

    To my understanding, slice means lst[start:end], and including start, excluding end. So how would I go about finding the "rest" of a list starting from an element n?

  4. How can I use Python built-in slice object? - Stack Overflow

    Oct 12, 2010 · The index or slice is passed to the methods as a single argument, and the way Python does this is by converting the slice notation, (1:10:2, in this case) to a slice object: slice(1,10,2).

  5. What is :: (double colon) in Python when subscripting sequences?

    Aug 10, 2010 · 22 When slicing in Python the third parameter is the step. As others mentioned, see Extended Slices for a nice overview. With this knowledge, [::3] just means that you have not …

  6. How to slice a list in Python - Stack Overflow

    How to slice a list in Python Asked 16 years, 2 months ago Modified 4 years ago Viewed 205k times

  7. How to slice a pandas DataFrame by position? - Stack Overflow

    I have a Pandas Data Frame object that has 1000 rows and 10 columns. I would simply like to slice the Data Frame and take the first 10 rows. How can I do this? I've been trying to use this: >&g...

  8. python - Ways to slice a string? - Stack Overflow

    Jul 31, 2018 · Python strings are immutable. This means that you must create at least 1 new string in order to remove the comma, as opposed to editing the string in place in a language like C.

  9. python - How to take column-slices of dataframe in pandas - Stack …

    May 19, 2012 · 27 You can slice along the columns of a DataFrame by referring to the names of each column in a list, like so:

  10. python - Understanding string reversal via slicing - Stack Overflow

    Python will "do the right thing" when filling in the start and stop so it iterates through the list backwards and gives you [10,9,8,7,6,5,4,3,2,1]. I've given the examples with lists, but strings are just another …