Given a dataset, write Python code using pandas to: 1. Fill missing numerical values with the column median. 2. Replace outliers in the 'income' column (using Z-score > 3) with the median. 3. Normalize 'feature1' and 'feature2' using StandardScaler. 4. Convert the 'gender' column to categorical type. 5. One-hot encode the 'location' column. 6. Remove rows where 'age' is negative.
Provides a Python code template for common data cleaning tasks: handling missing values, treating outliers, normalizing data, ensuring data type consistency, encoding categorical variables, and enforcing data integrity. Use for hands-on data preprocessing.