Wie konvertiere ich Schwimmspalten ohne Dezimalzahl in Polare? [geschlossen]

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Wie konvertiere ich Schwimmspalten ohne Dezimalzahl in Polare? [geschlossen]

by Anonymous » 24 Feb 2025, 12:22

Pandas-Code wie dieser, wenn eine Float-Spalte mit 1.0, 2.0, 3.0, entfernen

Code: Select all

df = pd.DataFrame({
"date": ["2025-01-01", "2025-01-02"],
"a": [1.0, 2.0],
"c": [1.0, 2.1],
})
print(df)
columns = df.columns.difference(["date"])
df[columns] = df[columns].map(lambda x: int(x) if x.is_integer() else x)
print(df)
< /code>
         date    a    c
0  2025-01-01  1.0  1.0
1  2025-01-02  2.0  2.1
date  a    c
0  2025-01-01  1  1.0
1  2025-01-02  2  2.1

Top