Python Forum
Slicing dataframe as series vs. dataframe?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Slicing dataframe as series vs. dataframe?
#1
I just figured out this works to print out every 10th row in one df:

df.iloc[::10,]
Why did I not need double brackets, though? In this case:
df.iloc[7]
I get a series and only if I use double brackets around the 7 do I get a one-row dataframe.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  renaming a column without a name in a dataframe Carbonpony 2 867 Jan-23-2025, 08:20 AM
Last Post: Carbonpony
  dataframe merge gunther 2 576 Jan-22-2025, 05:23 PM
Last Post: Pedroski55
  Running search/replace across Polars dataframe columns efficiently hobbycoder 3 2,215 Oct-28-2024, 03:18 AM
Last Post: hobbycoder
  Most efficient way to roll through a pandas dataframe? sawtooth500 2 1,109 Aug-28-2024, 10:08 AM
Last Post: Alice12
  Confused by the different ways of extracting data in DataFrame leea2024 1 659 Aug-17-2024, 01:34 PM
Last Post: deanhystad
  docx file to pandas dataframe/excel iitip92 1 2,510 Jun-27-2024, 05:28 AM
Last Post: Pedroski55
  FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries sawtooth500 14 7,864 Apr-24-2024, 01:42 AM
Last Post: sawtooth500
  Elegant way to apply each element of an array to a dataframe? sawtooth500 7 2,587 Mar-29-2024, 05:51 PM
Last Post: deanhystad
  Dataframe copy warning sawtooth500 4 2,162 Mar-25-2024, 11:38 PM
Last Post: sawtooth500
  FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries i sawtooth500 3 17,369 Mar-22-2024, 03:08 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020