Manipulating Built Dataframes
Apply function
df['column_name'] = df['column_name'].apply(
lambda x :
float(x.replace("$", "0",).replace(",", "").strip()))Insert column
df.insert(1, 'column_name', data)Resetting index
df = df.reset_index(drop=True)
pd.concat([s1, s2], ignore_index=True)Remove rows that do not contain numbers
df[pd.to_numeric(df['Funding'], errors='coerce').notnull()]Drop if all columns are Nan
df.dropna(axis=0, how='all')Clean up all cells in dataframe
def clean(row):
return row.replace("nan", "").strip()
df.applymap(clean)Drop rows with NAs in specific columns
Drop rows with specific strings
Drop rows with empty cells
Last updated
Was this helpful?