Skip to content

Instantly share code, notes, and snippets.

@nithyadurai87
Created June 11, 2021 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nithyadurai87/9cfbccf58bde2d84b2d0641e1aebf033 to your computer and use it in GitHub Desktop.
Save nithyadurai87/9cfbccf58bde2d84b2d0641e1aebf033 to your computer and use it in GitHub Desktop.
import pandas as pd
df = pd.DataFrame({'Languages': pd.Series(['Tamil','English']), 'Subjects': pd.Series(['Maths','Science','Social'])})
print (df)
print (df['Languages'].str.upper()) # lower(), swapcase(), islower(), isupper(), isnumeric()
print (df['Languages'].str.split('i'))
print (df['Languages'].str.contains('i'))
print (df['Languages'].str.len())
print (df['Subjects'].str.startswith('S')) # endswith()
print (df['Subjects'].str.count('e'))
print (df['Subjects'].str.find('e'))
print (df['Subjects'].str.findall('e'))
print (df['Languages'].str.replace('i','e'))
print (df['Languages'].str.cat(sep=','))
s = pd.Series(['Ramu','Somu','Jothi','Rathi','Jothi'])
print (s.str.get_dummies())
print (s.str.repeat(4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment