“Pandy dodają dwie kolumny łańcuchowe” Kod odpowiedzi

Pandy dodają dwie kolumny łańcuchowe

# if both columns are strings, you can concatenate them directly
df["period"] = df["Year"] + df["quarter"]

# If one (or both) of the columns are not string typed, you should convert it 
# (them) first,
df["period"] = df["Year"].astype(str) + df["quarter"]
Trained Tuna

Pandas DataFrame Dodaj dwie kolumny INT i String

df = df['Day'].map(str) + '-' + df['Month'].map(str) + '-' + df['Year'].map(str)
Wide-eyed Wren

Pandas DataFrame Dodaj dwie kolumny INT i String

df1 = df['1st Column Name'].map(str) + df['2nd Column Name'].map(str) + ...
Wide-eyed Wren

Odpowiedzi podobne do “Pandy dodają dwie kolumny łańcuchowe”

Pytania podobne do “Pandy dodają dwie kolumny łańcuchowe”

Więcej pokrewnych odpowiedzi na “Pandy dodają dwie kolumny łańcuchowe” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu