Forum Discussion

Ellie_1066's avatar
Ellie_1066
Copper Contributor
Mar 14, 2025
Solved

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...
  • Kidd_Ip's avatar
    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)
    

     

Resources