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 b...
- Mar 15, 2025
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)
Kidd_Ip
Mar 15, 2025MVP
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_1066
Mar 15, 2025Copper 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.