Skip to content

Instantly share code, notes, and snippets.

@le-dawg
Created June 25, 2017 21:09
Show Gist options
  • Save le-dawg/e5b0dc4b16cafe7014c1819c0c3e697c to your computer and use it in GitHub Desktop.
Save le-dawg/e5b0dc4b16cafe7014c1819c0c3e697c to your computer and use it in GitHub Desktop.
Python / Pandas snippets for the troubleshooting developer pt.1
  #Count occurences of string in dataframe
  #Check how many rows in DataFrame contain certain substring s in column col
print(len(df[df['col'].str.contains("s")].index.values[:]))
 
#Index of columns in dataframe containing string
#Get indices of rows that contain substring s in column col
print(df[df['col'].str.contains("s")].index.values[:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment