Demo_space_2 / data_preprocessing.py
Ganesh43's picture
Update data_preprocessing.py
9d0f8b1 verified
raw
history blame contribute delete
No virus
623 Bytes
import pandas as pd
def preprocess_csv(data):
"""
Preprocesses CSV data and returns a single string.
Args:
data: Either a DataFrame containing CSV data or a file path to a CSV file.
Returns:
A string containing the preprocessed text.
"""
if isinstance(data, pd.DataFrame):
# Process DataFrame directly
df = data
else:
# Read CSV from file path
df = pd.read_csv(data)
# Preprocess the data (replace with your specific logic)
# Example: Combine relevant columns into a single string
text = " ".join(str(word) for col in df.columns for word in df[col].tolist())
return text