2025-02-27, 21:52
Aus aktuellem Anlass hier ein einfaches Beispiel, wie man Werte in pandas Dataframes ersetzen kann:
import pandas as pd
# initialize data of lists.
data = {'Hersteller': ['VW', 'BMW', 'VW', 'Porsche'],
'Modell': ['Golf', '1er', 'Polo', '911']}
df = pd.DataFrame(data)
print(df,'\n')
df['Hersteller'] = df['Hersteller'].replace(
{"VW": "Volkswagen", "Horch": "Audi"})
print(df) |
import pandas as pd
# initialize data of lists.
data = {'Hersteller': ['VW', 'BMW', 'VW', 'Porsche'],
'Modell': ['Golf', '1er', 'Polo', '911']}
df = pd.DataFrame(data)
print(df,'\n')
df['Hersteller'] = df['Hersteller'].replace(
{"VW": "Volkswagen", "Horch": "Audi"})
print(df)
Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined.
Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.
More Posts - Website