benchmarks.wiki / Public workspace

DS-1000 / 102 / In pandas, how do I replace & with '&' from all columns where &AMP could be…

Problem

Answer published by the source. Consult the official source to check your work against its answer.

prompt

Problem:
In pandas, how do I replace & with '&' from all columns where &AMP could be in any position in a string?
For example, in column Title if there is a value 'Good & bad', how do I replace it with 'Good & bad'?


A:
<code>
import pandas as pd

example_df = pd.DataFrame({'A': ['Good &AMP; bad', 'BB', 'CC', 'DD', 'Good &AMP; bad'], 'B': range(5), 'C': ['Good &AMP; bad'] * 5})
def f(df=example_df):
    # return the solution in this function
    # result = f(df)
    ### BEGIN SOLUTION

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import