# ... your Python code def getDataframeInfo(df): dfInfo = pd.DataFrame(data={'DataFeatures':list(df)}) dfInfo['DataType'] = dfInfo['DataFeatures'].apply(lambda col: df.dtypes[col]) dfInfo['Null'] = dfInfo['DataFeatures'].apply(lambda col: df[col].isnull().sum(axis='index')) dfInfo['NullPercentage'] = dfInfo['Null'].apply(lambda nullCount: nullCount / df.shape[0]) dfInfo['Unique'] = dfInfo['DataFeatures'].apply(lambda col: df[col].nunique()) dfInfo['UniqueSample'] = dfInfo['DataFeatures'].apply(lambda col: df[col].unique()[0:5]) return dfInfo getDataframeInfo(YOUR_DATAFRAME_VARIABLE)