본문 바로가기

count10.3

Python Django에서 GROUP BY를 사용하여 쿼리하는 방법은 무엇인가요?, How to query as GROUP BY in Django? 질문 나는 모델을 쿼리합니다: Members.objects.all() 그리고 다음과 같이 반환됩니다: Eric, Salesman, X-Shop Freddie, Manager, X2-Shop Teddy, Salesman, X2-Shop Sean, Manager, X2-Shop 내가 원하는 것은 데이터베이스로 group_by 쿼리를 실행하는 최상의 Django 방법을 알고 싶습니다: Members.objects.all().group_by('designation') 물론 작동하지 않습니다. django/db/models/query.py에서 어떤 트릭을 사용할 수 있다는 것은 알고 있지만, 패치 없이 어떻게 할 수 있는지 궁금합니다. 답변 만약 집계를 하려면 ORM의 집계 기능을 사용할 수 있습니다: from .. 2023. 10. 18.
Flutter 컬럼 안에 플러터 그리드뷰. 어떤 해결책이 있을까요..?, Flutter Gridview in Column. What's solution..? 질문 나는 그리드뷰와 컬럼에 문제가 있습니다. 이 경우에, 나는 그리드뷰의 위쪽에 이미지를 넣고 싶습니다. 해결책을 주세요.. return new Container( child: new Column( children: [ new Container( child: new Image.asset( "assets/promo.png", fit: BoxFit.cover, ), ), new Container( child: new GridView.count( crossAxisCount: 2, childAspectRatio: (itemWidth / itemHeight), controller: new ScrollController(keepScrollOffset: false), shrinkWrap: true, scrollDi.. 2023. 9. 28.
Python 판다스 GroupBy 출력을 Series에서 DataFrame으로 변환하기, Converting a Pandas GroupBy output from Series to DataFrame 질문 다음과 같은 입력 데이터로 시작합니다. df1 = pandas.DataFrame( { "Name" : ["Alice", "Bob", "Mallory", "Mallory", "Bob" , "Mallory"] , "City" : ["Seattle", "Seattle", "Portland", "Seattle", "Seattle", "Portland"] } ) 이를 출력하면 다음과 같이 나타납니다: City Name 0 Seattle Alice 1 Seattle Bob 2 Portland Mallory 3 Seattle Mallory 4 Seattle Bob 5 Portland Mallory 그룹화는 간단합니다: g1 = df1.groupby( [ "Name", "City"] ).count() 그리고 출력.. 2023. 8. 1.