Skip to content

Commit

Permalink
Merge pull request #33 from KOSASIH/deepsource-transform-470c1dd2
Browse files Browse the repository at this point in the history
style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf
  • Loading branch information
KOSASIH authored May 11, 2024
2 parents 246eb71 + b09f686 commit dec9b62
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions data_science/data_preprocessing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pandas as pd
import numpy as np
import pandas as pd


def preprocess_data(data):
# Preprocess data using Pandas or NumPy
Expand All @@ -9,14 +10,18 @@ def preprocess_data(data):
data = data.fillna(data.mean())

# Normalize numerical data
numerical_data = data.select_dtypes(include=['int64', 'float64'])
numerical_data = (numerical_data - numerical_data.min()) / (numerical_data.max() - numerical_data.min())
numerical_data = data.select_dtypes(include=["int64", "float64"])
numerical_data = (numerical_data - numerical_data.min()) / (
numerical_data.max() - numerical_data.min()
)

# Encode categorical data
categorical_data = data.select_dtypes(include=['object'])
categorical_data = data.select_dtypes(include=["object"])
encoded_data = pd.get_dummies(categorical_data)

# Concatenate the preprocessed data
preprocessed_data = np.concatenate([numerical_data.values, encoded_data.values], axis=1)
preprocessed_data = np.concatenate(
[numerical_data.values, encoded_data.values], axis=1
)

return preprocessed_data

0 comments on commit dec9b62

Please sign in to comment.