If you want to print the name of a column, just do df.columns[]
To print a column, try df.columns[<"name of column">]
To print the number of rows/columns, len(df.rows) or len(df.columns)
to identify the class/type of object, type()
Simple iteration: for i in range (, )
df_python=survey_df[['column name1', 'column name 2']]
to print out unique values in a column: int df[col].unique()
If you want to manually create a dataframe, do this:
df= pd.DataFrame(columns=['col1', 'col2'])
df['col1']=['data','data2','data3'] or
df['col1']=[84,253,3]
If you want to create a new column that transforms existing text values into a numeric value, do this:
=pd.merge(,[["name of column 1 to bring", "name of column 2 to bring"]],left_on="which column from df 1 to match",right_on="which column from df 2 to match",how='left')
Get rid of columns that aren't helpful: del df['column_name']
to assign a value to a specific cell in a df, df.ix[0, 'COL_NAME'] = x
No comments:
Post a Comment