Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

FeatureGroupSubGroup: nth level subgroups

未關閉
#1,758 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
25/100
Issue 類型
功能
描述清晰度
需要釐清
活躍度
停滯
技術堆疊
jupyter-notebook, python

研究方向

從提供的 FeatureGroupSubGroup 建構和 Jupyter/VS Code 重現中產生的 TESTING.html 開始;驗證超過一層的巢狀子群組是否如預期呈現及切換。定義所需的第 n 層行為,並使用最小地圖重現加以確認,包括所述的點顯示條件。

由索引模型根據 Issue 內容生成。

描述

More info needed

Describe the bug
I am using quite a few levels of recursion to generate a map that has subgroups within subgroups, and im not sure how to fix the issue, or if there is a better method.

To Reproduce
theres alot going on here... the repeated for loops are to keep the buttons ordered by hierarchy.

import folium
from folium import plugins

#####################################################################################
coord = df['Location'].apply(fetch_lat_lon)
df['Lat'] = coord.apply(lambda x: x[0] if isinstance(x, tuple) else None)
df['Long'] = coord.apply(lambda x: x[1] if isinstance(x, tuple) else None)

df['Result'] = (~df['Impounded'].isna().astype(int)).apply(lambda x: _results[x])
df['Interval'] = (datetime.now() - df.index).days
df['Weekday'] = df.index.weekday.map(lambda x: _days[x])
df['Time'] = df.index.hour

df = df[~df['ID'].isna()]                                                           
#####################################################################################
m = folium.Map(location=[0, 0], zoom_start=14)


results = {}
intervals = {}
days = {}
times = {}

_results = ['Complete', 'Canceled']
_intervals = [7, 30, 90, 365] ## days before now
_days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
_times = range(24)

for result in _results:

    results[result] = folium.FeatureGroup(name = result)
    m.add_child(results[result])

for result in _results:
    for interval in _intervals: 

        intervals[f'{result}_{interval}'] = plugins.FeatureGroupSubGroup(results[result], f'{interval} Days')
        m.add_child(intervals[f'{result}_{interval}'])

for result in _results:
    for interval in _intervals: ## days before now
        for day in _days:

            days[f'{result}_{interval}_{day}'] = plugins.FeatureGroupSubGroup(intervals[f'{result}_{interval}'], day)
            m.add_child(days[f'{result}_{interval}_{day}'])

for result in _results:
    for interval in _intervals: ## days before now
        for day in _days:
            for time in _times:
                
                if time < 12:
                    if time !=0:
                        times[f'{result}_{interval}_{day}_{time}'] = plugins.FeatureGroupSubGroup(days[f'{result}_{interval}_{day}'], f'{time} AM')
                        m.add_child(times[f'{result}_{interval}_{day}_{time}'])
                    else: 
                        times[f'{result}_{interval}_{day}_{time}'] = plugins.FeatureGroupSubGroup(days[f'{result}_{interval}_{day}'], f'{time + 12} AM')
                        m.add_child(times[f'{result}_{interval}_{day}_{time}'])
                elif time > 12:
                    times[f'{result}_{interval}_{day}_{time}'] = plugins.FeatureGroupSubGroup(days[f'{result}_{interval}_{day}'], f'{time - 12} PM')
                    m.add_child(times[f'{result}_{interval}_{day}_{time}'])
                else:
                    times[f'{result}_{interval}_{day}_{time}'] = plugins.FeatureGroupSubGroup(days[f'{result}_{interval}_{day}'], f'{time} PM')
                    m.add_child(times[f'{result}_{interval}_{day}_{time}'])

for result in _results:
    for interval in _intervals: ## days before now
        for day in _days:
            for time in _times:

                group = times[f'{result}_{interval}_{day}_{time}']

                condition = ((df['Result'] == result) &
                             (df['Interval'] <= interval) &
                             (df['Weekday'] == day) &
                             (df['Time'] == time)
                )

                _df = df[condition].dropna()

                for i in range(len(_df)):
                    lat = _df['Lat'].iloc[i] - _df['Lat'].mean()
                    long = _df['Long'].iloc[i] - _df['Long'].mean()

                    folium.Marker([lat, long]).add_to(group)
            
folium.LayerControl(collapsed=True).add_to(m)

m.save('TESTING.html')

Expected behavior
When all button conditions are met, points will display,

Environment (please complete the following information):

  • chrome
  • jupyter notebooks
  • vs code
主要語言
Python
星號
7.4k
分支
2.3k
平均合併
2 天 4 小時
30 天內合併 PR
10

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

python-visualization/folium 的其他 Issue

查看 python-visualization/folium 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。