Python Forum

Full Version: Newbie question to return only the index of a dataframe
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.