Skip to content

Instantly share code, notes, and snippets.

@roycoding
Created October 5, 2017 20:46
Show Gist options
  • Select an option

  • Save roycoding/bbecda07b594870a878f2f71f9fb15a8 to your computer and use it in GitHub Desktop.

Select an option

Save roycoding/bbecda07b594870a878f2f71f9fb15a8 to your computer and use it in GitHub Desktop.

Revisions

  1. roycoding created this gist Oct 5, 2017.
    17 changes: 17 additions & 0 deletions sandwich.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    def sandwich(df, rows=3):
    '''
    Display n rows of head and tail of dataframe.
    Input:
    df - dataframe of interest
    rows - integer number of rows from each end of dataframe to display
    Output:
    dataframe
    '''

    fill_row = pd.DataFrame(np.array(['...']*df.shape[1]).reshape(1, -1),
    columns=df.columns,
    index=['...'])

    return pd.concat([df.head(rows), fill_row, df.tail(rows)])