0

I got:

df1.shape: 51616 rows × 1 columns

df2.shape: 2322026 rows × 10 columns

After I do:

df2.update(df1)

I got error:

Shape of passed values is (5624095, 10), indices imply (2322036, 10)

What is wrong with my data?

Dishin H Goyani
  • 7,195
  • 3
  • 26
  • 37
lol
  • 37
  • 1
  • 6
  • 1
    You have different row count. df.update requires both dataframe to have equal row count – Yash Sep 19 '20 at 12:12
  • accroding to the document, they can be different. df = pd.DataFrame({'A': [1, 2], 'B': [400, 500]}) new_df = pd.DataFrame({'B': [4, 5, 6], 'C': [7, 8, 9]}) df.update(new_df) – lol Sep 19 '20 at 12:15
  • could you let me know the documentation that you are referring? I have [link](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.update.html) – Yash Sep 19 '20 at 12:17
  • you could try my code in the comment. it works fine. – lol Sep 19 '20 at 12:22
  • looks like your code works. But cant help you without more information. Is both df1 and df2 dataframe, because ```51616 rows × 1 columns``` could imply that you are updating on a series – Yash Sep 19 '20 at 12:36

1 Answers1

0

indices are duplicated.After reomved the duplicates, it works.

lol
  • 37
  • 1
  • 6