If the phone number and name are the same, I would like to put the shipping number at the back of the member number and send it to a new csv file.
Please give me some tips on what to do.
python csv list dictionary
You can use pd.merge.
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.merge.html
>>> import pandas as pd
>> a = pd.DataFrame ({"Name": ["Younghee", "Minsu"], "Phone Number": ["424", "114"], "Member Number": ["110", "104"]})
>> b = pd.DataFrame ({"Name":["Younghee", "Minsu"], "Phone Number":["424", "114"], "Shipping Number":["12341", "12355"]})
>>> a
Name Phone Number Member Number
0 Younghee 424 110
1 Minsu 114104
>>> b
Name Phone Number Shipping Number
0 Younghee 424 12341
1 Minsu 114 12355
>>> c = pd.merge(a,b,on=["Name", "Phone Number"])
>>> c
Name Phone Number Member Number Delivery Number
0 Younghee 424 110 12341
1 Minsu 114 104 12355
>>> print(c.to_markdown())
| | Name | Phone number | Member number | Shipping number |
|---:|:-------|-----------:|-----------:|-----------:|
| 0 | Younghee | 424 | 110 | 12341 |
| 1 | Minsu | 114 | 104 | 12355 |
© 2024 OneMinuteCode. All rights reserved.