Python Forum
Pandas copying wrong values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas copying wrong values
#1
Can someone explain me this?
Python 3.7
pandas 0.25.3

import pandas as pd

foo = pd.concat([pd.DataFrame({'foo': [10,20]}), pd.DataFrame({'foo': [30,40]})])
bar = pd.DataFrame({'bar': [1, 2, 3, 4]})

foo["bar"] = bar["bar"]

print((foo["bar"].values == bar["bar"].values).all())
print(foo)
Output:
False foo bar 0 10 1 1 20 2 0 30 1 1 40 2
Reply


Messages In This Thread
Pandas copying wrong values - by vmarg - Jan-05-2020, 10:52 PM
RE: Pandas copying wrong values - by sandeep_ganga - Jan-06-2020, 06:30 AM
RE: Pandas copying wrong values - by vmarg - Jan-06-2020, 09:45 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Assigning conditional values in Pandas Scott 3 811 Dec-19-2023, 03:10 AM
Last Post: Larz60+
Question How does one clean a populated table in MySQL/MariaDB? Copying values across tables? BrandonKastning 2 1,575 Jan-17-2022, 05:46 AM
Last Post: BrandonKastning
  PANDAS: DataFrame | Saving the wrong value moduki1 0 1,556 Jan-10-2022, 04:42 PM
Last Post: moduki1
  pandas: Compute the % of the unique values in a column JaneTan 1 1,784 Oct-25-2021, 07:55 PM
Last Post: jefsummers
  update values in one dataframe based on another dataframe - Pandas iliasb 2 9,298 Aug-14-2021, 12:38 PM
Last Post: jefsummers
  Pandas + Groupby + Filter unique values JosepMaria 1 2,880 Jun-15-2020, 08:15 AM
Last Post: JosepMaria
  sort values of a column pandas karlito 2 2,512 Oct-22-2019, 06:11 AM
Last Post: karlito
  Pandas Import CSV count between numerical values within 1 Column ptaylor520 3 2,666 Jul-16-2019, 08:13 AM
Last Post: ptaylor520
  Custom timeinterval converted to hourly values using Pandas? SinPy 1 2,795 Jun-07-2019, 05:06 AM
Last Post: heiner55
  Splitting values in column in a pandas dataframe based on a condition hey_arnold 1 4,171 Jul-24-2018, 02:18 PM
Last Post: hey_arnold

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020