Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Newbie question to return only the index of a dataframe
import datetime
import numpy as np
import pandas as pd

def get_index(df, offset):
    print(df.iloc[offset:df.index.max(), 0:0])
    return (df.iloc[offset:df.index.max(), 0:0])

data={'id': [0,1,2,3], 'A':[1.1, 1.2, 1.3, 1.4]}
idx1 = get_index(df1, 1)
print('idx1 = ', idx1)    
I have a simple dataframe, I want to write a function to return only a part of index.
But my code did NOT work, the result is empty dataframe.
How I can reach my goal?
Please advise.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Python & Dataframe basic question georgialtr 0 441 Apr-06-2020, 03:59 PM
Last Post: georgialtr
  newbie: loop, modify dataframe cells expat_th 5 410 Mar-03-2020, 09:05 PM
Last Post: jefsummers
  Getting Index Error - list index out of range RahulSingh 2 940 Feb-03-2020, 07:17 AM
Last Post: RahulSingh
  How to find index of a particular value in a dataframe ankitawadhwa 0 333 Jan-21-2020, 09:45 PM
Last Post: ankitawadhwa
  How to add data to the categorical index of dataframe as data arrives? AlekseyPython 1 494 Oct-16-2019, 06:26 AM
Last Post: AlekseyPython
  Applying operation to a pandas multi index dataframe subgroup Nuovoq 1 727 Sep-04-2019, 10:04 PM
Last Post: Nuovoq
  How to return values from For Loop via return in a function AykutRobotics 14 2,374 Jan-08-2019, 04:12 AM
Last Post: stullis
  Simple pandas dataframe question popohoma 1 870 Jan-03-2019, 05:00 PM
Last Post: ashlardev
  How to get first and last row index of each unique names in pandas dataframe SriRajesh 1 2,083 Oct-13-2018, 07:04 AM
Last Post: perfringo
  DataFrame index issue Astrikor 2 1,119 Aug-25-2018, 04:25 PM
Last Post: Astrikor

Forum Jump:

Users browsing this thread: 1 Guest(s)