df = pd .Dataframe (my_dict )
Dictionary to DataFrame with row labels
row_labels = ['label0' , 'label1' ]
df .index = row_labels
from csv file
`df = pd .read_csv (file_name )
csv to DataFrame with row labels
df = pd .read_csv (file_name , index_col = 0 )
Indexing and Selecting Data
Get column(s) as DataFrame
d1 = df [['col_1' ]]
d2 = df [['col_1' , 'col2' ]]
Filter, Modify, Impute DataFrame
Add new column to DataFrame by using another column:
df [lenght_column_a ] = df ['column_a' ].apply (len )
df [capitalized_column_b ] = df ['column_b' ].apply (str .upper )
pd .to_numeric (df ['Column Name' ], errors = 'coerce' )
Change data type of DataFrame column
df .column_name = df .column_name .astype (int )
df .drop (['columnheading1' , 'columnheading2' ], axis = 1 , inplace = True )
Impute Missing Values with 0
df .update (df [['a' ,'b' ,'c' ]].fillna (0 ))
pandas .set_option ('display.width' , 100 )
pandas .set_option ('precision' , 3 )
df .shape
df .dtypes
df .info ()
df .describe
df .corr (method = 'pearson' )
df .skew () #Values closer to zero show less skew.