import pandas as pd
data = {
'number': [1, 2, 5, 2, 2, 5],
'letter': ['A', 'B', 'D', 'D', 'D', 'D']
}
df = pd.DataFrame(data)
# Count the occurrences of each number in the "number" column
count_per_number = df['number'].value_counts()
# Filter the DataFrame by keeping only the rows where the number has multiple matches in the "letter" column
result_df = df[df['number'].isin(count_per_number[count_per_number > 1].index)]
print(result_df)
1条答案
按热度按时间qojgxg4l1#
字符串
输出量:
型