I would like to export cleaned dataset into CSV. I get the error message:
AttributeError Traceback (most recent call last)
Cell In[57], line 20
18 # Save the cleaned and updated dataset to a CSV file
19 output_file_path = r’D:UsersDesktopProjektAnalitiksdata2_Interimdropped_rows_columns.csv’
—> 20 data_cleaned_dropped.to_csv(output_file_path, index=False)
22 print(f”Dataset saved to {output_file_path}”)
AttributeError: ‘tuple’ object has no attribute ‘to_csv’
Portion of code:
Columns to drop based on the missing percentage
columns_to_drop = [
‘Nazwa’,
‘Czas ostatniej modyfikacji’,
‘Jeżeli pominięto branżę, na której się znasz dopisz ją:’,
‘Jeżeli jest obszar, na którym się znasz i chcesz go wykorzystać, dopisz go:’,
‘Masz jakiś pomysł na projekt data? Napisz nam o tym. Jeżeli to nie ten moment, pozostaw puste pole.’
]
Dropping the specified columns from the cleaned dataset
data_cleaned_dropped = data_cleaned.drop(columns=columns_to_drop)
Checking the size of the cleaned dataset after dropping columns
dataset_size = data_cleaned_dropped.shape
Display the size of the cleaned dataset
print(“Number of rows:”, dataset_size[0])
print(“Number of columns:”, dataset_size[1])
Display the first few rows of the updated dataset to confirm the columns are dropped
print(data_cleaned_dropped.head())
Checking the size of the original dataset
original_dataset_size = data.shape
Display the size of the original dataset
print(“Number of rows:”, original_dataset_size[0])
print(“Number of columns:”, original_dataset_size[1])
Checking the size of the original dataset
data_cleaned_dropped = data_cleaned_dropped.shape
Display the size of the original dataset
print(“New number of rows:”, data_cleaned_dropped[0])
print(“New number of columns:”, data_cleaned_dropped[1])
Save the cleaned and updated dataset to a CSV file
output_file_path = r’D:UsersDesktopProjektAnalitiksdata2_Interimdropped_rows_columns.csv’
data_cleaned_dropped.to_csv(output_file_path, index=False)
print(f”Dataset saved to {output_file_path}”)
Exporting cleaned dataset to CSV.
rejent is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.