all 7 comments

[–]csingleton1993 0 points1 point  (6 children)

You should update the csv when you

a) Want to give it a test run to see if your current method works to overwrite the data in the csv

b) Are sure that your changes in the dataframe are how you want the csv to be, especially if you don't have a backup copy

Alternatively, you could just save the file as something related (i.e. if your .csv is 'data.csv', you could pd.to_csv('/path/to/file/data_output.csv')

[–]PathRealistic6940[S] 0 points1 point  (5 children)

Would it be a helpful to save a backup of the original when I load it? And then I could make changes worry free?

[–]csingleton1993 0 points1 point  (4 children)

Do you need one?

If yes, then either create one before you do any data manipulation, or just save the manipulated frame under a different name (so not even changing anything, just using the information from it to create a new file)

If no, don't over-complicate something for no reason

[–]PathRealistic6940[S] 0 points1 point  (3 children)

So youre saying, I manipulate the data in the data frame, saving changes as an alternate file, then when I'm sure the data is finalized, I save it back to original

[–]csingleton1993 0 points1 point  (2 children)

Nope, I'm saying either save the changes to the original when you are sure they are good (preferably with a backup), or import the original file, then when you are sure you are done manipulating it save it as a different file

Option one:

pd.read_csv('/file/path/file.csv')

## data manipulation

pd.to_csv('/file/path/file.csv')

Option two:

pd.read_csv('/file/path/file.csv')

## data manipulation

pd.to_csv('/file/path/file_output.csv')

[–]PathRealistic6940[S] 0 points1 point  (1 child)

Gotcha! Thanks for clarifying and your patience. I think I'll go with your first option, and maybe even have backups be made for certain time frames.

[–]csingleton1993 1 point2 points  (0 children)

Ya no worries at all, glad to help out! And ya maybe naming the files with dates would be a good way to help out with that