Я пытаюсь написать сценарий Python, который позволяет пользователю вводить имя столбца, а затем распечатывать счетчики значений этого столбца из pandas DataFrame. Вот что у меня есть на данный момент:
def count_unique_values(df, column_list):
for col in column_list:
if col not in df.columns:
print(f"Column '{col}' not found in the DataFrame.\n")
continue
print(f"\nColumn: {col}")
counts = df[col].value_counts()
print(counts, "\n")
print(col=input("Input column name: ")
Подробнее здесь: https://stackoverflow.com/questions/798 ... -dataframe
Мобильная версия