Skip to content

Instantly share code, notes, and snippets.

@nithyadurai87
Created June 12, 2021 08:29
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/da42bdc2cae5714a3176066d3e9289b8 to your computer and use it in GitHub Desktop.
Save nithyadurai87/da42bdc2cae5714a3176066d3e9289b8 to your computer and use it in GitHub Desktop.
import pandas as pd
import numpy as np
l2 = [[90,83,67,83,45],[68,89,75,56,73],[58,88,60,90,100]]
df = pd.DataFrame(l2,columns=['Tamil','English','Maths','Science','Social'],index=['Ramesh','Suresh','Kamesh'],dtype='int32')
df = df.rolling(window=3).mean()
print (df)
print (df.isnull())
print (df.notnull())
print (df.dropna())
print (df.fillna(0))
print (df.fillna(method='bfill')) # pad / fill for forward fill; bfill / backfill from backward
print (df.fillna(method='bfill',limit=1))
print (df.sum())
print (df.replace({72:100}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment