Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
110 views
in Technique[技术] by (71.8m points)

python - finding where index from one dataframe is not in another dataframe

I have two dataframes, one is called now & the other called old. Both have a string index. I am trying to find where a index value is in the now dataframe but not in the old dataframe.

I write tried the line below & it returns a series of True values

new_deals = now.index.isin(old.index)

However the now dataframe has an index value '4025542MM' which is not in the old dataframe & when I test the line below it returns False. So I'm confused why when I use the isin function it is returning True?

'4025542MM' in old.index = False

update

Its hard to copy data examples across. Below is a subset of some of the index values. The old dataframe data comes from sql and the index column is nvarchar(20) in sql server. The now dataframe data is coming from a text file.

I have tried using strip() but it makes no difference. I don't believe there is any extra white space as far as I can tell. In both dataframes the column is of type object.

 3000093MM
 3000161MM
 3000166MM
 3000273MM
 3000285MM
 3000291MM
 3000354MM
 3000458MM
 3000547MM
 3000773MM
 3000938MM
 3001080MM
question from:https://stackoverflow.com/questions/66060595/finding-where-index-from-one-dataframe-is-not-in-another-dataframe

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...