Skip to content

Instantly share code, notes, and snippets.

@nithyadurai87
Created June 11, 2021 09:00
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/ff31ea4d3ee2d471e08cb38f71f97357 to your computer and use it in GitHub Desktop.
Save nithyadurai87/ff31ea4d3ee2d471e08cb38f71f97357 to your computer and use it in GitHub Desktop.
import pandas as pd
l1 = [90,83,67,83,45]
l2 = [[90,83,67,83,45],[68,89,75,56,73],[58,88,60,90,100]]
df = pd.DataFrame(l2)
print (df)
print (df[2])
print (df[:2])
print (df[-2:])
df = pd.DataFrame(l2,columns=['Tamil','English','Maths','Science','Social'],index=['Ramesh','Suresh','Kamesh'],dtype='int32')
print (df)
print (df['Maths'])
print (df[:'Suresh'])
print (df['Suresh':])
s = pd.Series(l1,index=['Tamil','English','Maths','Science','Social'])
print (s[['Tamil','Social']])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment