Forum Discussion
Ellie_1066
Mar 14, 2025Copper Contributor
Complicated data analys
| Enkel | Avslutande | Heder | ||||
| k2 | b2 | n2 | k1 | b1 | n1 | Ö |
| k3 | b3 | n3 | k9 | b9 | n9 | S |
| k4 | b4 | n4 | V | |||
| k5 | b5 | n5 | N | |||
| k6 | b6 | n6 | W | |||
| k7 | b7 | n7 | G | |||
| k8 | b8 | n8 | R | |||
| hand 1 | |||||
| pon | kan | result | |||
| b2 | |||||
| b1 | |||||
| ö | |||||
How about Python:
import pandas as pd # Create your data data = { 'Hand': ['pon', 'kan', ''], 'Value1': ['b2', 'b1', 'ö'], 'Result': [0, 0, 0] } df = pd.DataFrame(data) # Define a function for assigning numeric values def assign_result(row): if row['Value1'] == 'b2': return 10 elif row['Value1'] == 'b1': return 20 elif row['Value1'] == 'ö': return 30 else: return 0 # Apply the function to the DataFrame df['Result'] = df.apply(assign_result, axis=1) print(df)
4 Replies
- m_tarlerBronze Contributor
I'm not sure what you need. The top part almost looks like chess references to me. But it sounds like you want a simple tabular substitution. Try using something like XLOOKUP. If you can give a sample sheet it may be easier to help. If you can't post it here try sharing with OneDrive or a similar cloud option.
How about Python:
import pandas as pd # Create your data data = { 'Hand': ['pon', 'kan', ''], 'Value1': ['b2', 'b1', 'ö'], 'Result': [0, 0, 0] } df = pd.DataFrame(data) # Define a function for assigning numeric values def assign_result(row): if row['Value1'] == 'b2': return 10 elif row['Value1'] == 'b1': return 20 elif row['Value1'] == 'ö': return 30 else: return 0 # Apply the function to the DataFrame df['Result'] = df.apply(assign_result, axis=1) print(df)- Ellie_1066Copper Contributor
I had hoped fore a solution whitout phyton but it is the result I wanted to achive. Glad you could understand my midnight ramble after 5 h of staring at this problem.
- Ellie_1066Copper Contributor
My description of the problem wasent the best if clarification is nedded let me know