In [25]:
import pandas as pd
df = pd.DataFrame({'col1':[1,2,3,4],'col2':[444,555,666,444],'col3':['abc','def','ghi','xyz']})
In [5]:
df.head(n=1)
Out[5]:
In [3]:
df
Out[3]:
In [7]:
df['col2'].unique()
Out[7]:
In [8]:
df['col2'].nunique()
Out[8]:
In [9]:
newdf = df[(df['col1']>2) & (df['col2']==444)]
In [12]:
df[(df["col2"]>450) & (df["col2"]<600)]
Out[12]:
In [13]:
def doub(x):
return x*2
In [15]:
doub(9)
Out[15]:
In [16]:
df
Out[16]:
In [17]:
df['col2'].apply(doub)
Out[17]:
In [18]:
df['col3'].apply(len)
Out[18]:
In [19]:
df['col2'].sum()
Out[19]:
In [26]:
#del df['col1']
df
Out[26]:
In [29]:
df.index
df.columns
Out[29]:
In [34]:
df.sort_values('col3',ascending=False)
Out[34]:
In [35]:
df.isnull()
Out[35]:
No comments:
Post a Comment