比方说,我们有以下数据集:熊猫:标准化组内
import pandas as pd
data = [('apple', 'red', 155), ('apple', 'green', 102), ('apple', 'iphone', 48),
('tomato', 'red', 175), ('tomato', 'ketchup', 96), ('tomato', 'gun', 12)]
df = pd.DataFrame(data)
df.columns = ['word', 'rel_word', 'weight']
我想重新计算权重,使他们每个组中总结到1.0(苹果,番茄在例子中)并保持相关权重(例如苹果/红色苹果/绿色仍然应该是155/102)。
您可以添加所需的O-本安输出? – jezrael
请在单独的专栏中提及预期输出以便更好地理解 – JKC