Skip to content

Commit

Permalink
Adds function for previewing contents of df
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkokotila committed Feb 20, 2020
1 parent 81bc6c5 commit 0325702
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions wrangle/df/df_print_values.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def df_print_values(data, n=5):

'''Shows the most common values for each column
in a dataframe.
data | DataFrame | a pandas dataframe with the data
n | int | Number of most common values to show
'''

for col in data.columns:

length = len(col)
dashes = "-" * length

print("%s \n%s" % (col, dashes))
print(data[col].value_counts().head(n))
print("\n")

0 comments on commit 0325702

Please sign in to comment.