vendredi 13 mars 2020

Replace strings from column with unique random strings

I have a a csv that has multiple columns, one of these columns consists of strings.

I start with just reading the csv file and then just using two columns

df = pd.read_csv("MyDATA_otherstring.csv", usecols=["describe_file", "data_numbers"])

This is the output

    describe_file   data_numbers
0   This is the start of the story  7309.0
1   This is the start of the story  35.0
2   This is the start of the story  302.0
3   Difficult part  7508.5
4   Difficult part  363.0

In around 10k rows, there are around 150 unique strings. These strings appear multiple times within the file.

My goal Filter by the first string example ``` This is is the start of the story''' and replace it with a random string.

I want to run over all the strings in that column and replace them with unique strings

I have looked into the random library and some questions that have been asked here, unfortunately I have not found anything that would help me.




Aucun commentaire:

Enregistrer un commentaire