Python Forum
Comparing two columns with same value but different font format
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Comparing two columns with same value but different font format
#1
Hi! I have a column of a dataframe with city names in capital letters and I wanted to compare it with the cities column of another dataframe with regular letters. It would be like a join. Join the two columns to compare the values ​​and search if any of them are missing. Below an example of the columns and values:

df1([CITY])
df1
CITY
WASHINGTON D.C.
NEW YORK
SAN DIEGO

df2([City])
df2
City
Washington D.C.
New York
San Diego
Reply
#2
just cast both strings to lower (or upper) then compare:

example:
>>> city1 = 'WASHINGTON D.C.'
>>> city2 = 'Washington D.C.'
>>> 
>>> # without changing case:
>>> city1 == city2
False
>>> 
>>> # with case change:
>>> city1.lower() == city2.lower()
True
>>> 
>>> # original variable names remain as they were:
>>> city1
'WASHINGTON D.C.'
>>> city2
'Washington D.C.'
>>>
doug2019 likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  comparing columns arvin 5 1,075 Dec-14-2022, 01:54 PM
Last Post: paul18fr
  How to properly format rows and columns in excel data from parsed .txt blocks jh67 7 1,892 Dec-12-2022, 08:22 PM
Last Post: jh67
  Load external font and does not show font in the window ATARI_LIVE 16 8,192 Feb-05-2021, 10:36 PM
Last Post: EthanPayne
  Comparing columns of Matrix stored in .txt files JoelFooCJ 2 2,271 Dec-11-2019, 07:21 AM
Last Post: JoelFooCJ
  Add DSIG to TTF font using ttx font tool Adrian 1 3,788 Nov-11-2017, 12:05 PM
Last Post: Adrian

Forum Jump:

User Panel Messages

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