有一个伟大的。
我的df.column看起来像:
Windows
Windows
Mac
Mac
Mac
Linux
Windows
...
我想在这个df.column向量中用'Other‘替换低频类别。例如,我需要我的df.column看起来像
Windows
Windows
Mac
Mac
Mac
Linux -> Other
Windows
...
我想重命名这些罕见的类别,以减少在我的回归因素的数量。这就是我需要原始向量的原因。在python中,在运行命令获取频率表之后,我得到:
pd.value_counts(df.column)
Windows
我有这个类别的MySql表:
id , name , parent
现在,使用这个function,我在selectbox和optgroup html标记中列出了类别:
$options = array();
$categories = DataAccess::fetch("
SELECT
* , p.name AS parent
FROM
cats AS child
INNER JOIN
cats AS p ON p.id = child.parent
");
foreach($categories as $category){
如果我的标题误导了您,请原谅,但我在尝试根据所选类别生成列表时遇到了问题,虽然我可以更改类别,但它仍然保留了先前类别选择中列表的值
category = os.environ['CAT']
item = os.environ['ITEM']
""" ezygate.Job.getItems is the code of the inhouse tool i'm using to derive the list of items """
itemList = ezygate.job.getItems({