How to merge first and last value of each name?

16 views
Skip to first unread message

deepti gautam

unread,
Feb 18, 2022, 4:54:05 AM2/18/22
to datameet
Hi all,

I have a data frame that includes yearweek (week of the year),  entity_name, and deposit_volume_btc (volume for each entity based on week of the year). How I can merge the first and last deposit_volume for each entity name?

For example:
Screenshot 2022-02-14 at 4.24.57 PM.png
- AAX 20220 deposit_volume should be merged with AAX 202152 and similarly, AltCoin Trader 20220 deposit volume should be merged with AltCoin 202132.

Dilawar Singh

unread,
Feb 18, 2022, 11:22:55 PM2/18/22
to datameet
Look at 'difflib.SequenceMatcher' (https://docs.python.org/3/library/difflib.html#difflib.SequenceMatcher)  in the Python ecosystem. Your favorite language may have something similar. Essentially, you are need to compute 'similarity' between two strings.

If your prefix e.g.  AltCoin in "AlCoin Trader 20220" and "AltCoin 202132" are fixed and have no typos, you can solve it by regular expressions (https://docs.python.org/3/library/re.html). Regular Expressions (regex) are pretty well-supported even in GUI-based office suites.

-- Dilawar
Reply all
Reply to author
Forward
0 new messages