1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Pandas loop and anonymise data

Discussão em 'Python' iniciado por Stack, Setembro 17, 2024.

  1. Stack

    Stack Membro Participativo

    I need to read an excel file and loop over rows, retain value for a column Location, anonymise the other values for the same column, and output the result for all combinations to seperate pdf files

    Original DF

    | Location | Patients | Deceased | Rank |
    |-----------|----------|----------|------|
    | Leicester | 2000 | 13 | 1 |
    | Coventry | 2200 | 24 | 2 |
    | Norwich | 3000 | 56 | 3 |
    | Sheffield | 2800 | 65 | 4 |
    | Luton | 1800 | 90 | 5 |


    Desired DF #1

    | Location | Patients | Deceased | Rank |
    |-----------|----------|----------|------|
    | Leicester | 2000 | 13 | 1 |
    | ######## | 2200 | 24 | 2 |
    | ######## | 3000 | 56 | 3 |
    | ######## | 2800 | 65 | 4 |
    | ######## | 1800 | 90 | 5 |


    Desired DF #2

    | Location | Patients | Deceased | Rank |
    |-----------|----------|----------|------|
    | ######## | 2000 | 13 | 1 |
    | Coventry | 2200 | 24 | 2 |
    | ######## | 3000 | 56 | 3 |
    | ######## | 2800 | 65 | 4 |
    | ######## | 1800 | 90 | 5 |


    I want to write out each DF using pd.to_html and then convert.

    I'm finding it hard to figure out how to implement this in pandas or how best use iterrows and faker to achieve this or whether a replace() would do in each iteration even.

    Continue reading...

Compartilhe esta Página