So my issue is every time I do some cleaning in the dataframe, the modified dataframe is not saving the changes to a new csv. Is something wrong with my code?
import pandas as pd
housing = pd.read_csv(csv_path)
# Modifying the data frame (removing any strings)
headers = ['Sold Price', 'Longitude', 'Latitude', 'Land Size', 'Total Bedrooms', 'Total Bathrooms', 'Parking Spaces']
for header_index in range(len(headers)):
for index in housing.index:
row = housing.at[index, headers[header_index]]
if row is not int or row is not float:
row = ''
housing.to_csv('propertyupdated.csv')
After calling housing.to_csv('propertyupdated.csv')
, I went to the directory and checked the csv file. It was the original file, my modifications have not been saved into the new csv file. But I know that I have changed the dataframe in python.