Skip to content

Instantly share code, notes, and snippets.

View keNzi's full-sized avatar
🎯
Focusing

keNzi keNzi

🎯
Focusing
View GitHub Profile
@keNzi
keNzi / ga4_reports.py
Created February 20, 2024 09:18
retrieve GA4 data using API with UTF-8 metrics name. Save to JSON file using Pandas DataFrame
import os
import pandas as pd
from google.analytics.data_v1beta import BetaAnalyticsDataClient
from google.analytics.data_v1beta.types import (
DateRange,
Dimension,
Metric,
MetricType,
@keNzi
keNzi / find_most_common_number
Last active May 13, 2018 15:16
find most common number
numbers = [1, 2, 3, 2, 2, 2, 2, 2, 9, 1]
def find_most_common_number(numbers):
from collections import Counter
return print(Counter(numbers).most_common(1)[0][0])
def find_most_common_number(numbers):
count_list = [[x, numbers.count(x)] for x in set(numbers)]
def xmassTree(floors):
for x in [z for z in range(1, floors * 2 + 1, 2)]:
floors -= 1
print(' ' * floors, '*' * x)
xmassTree(5)
def xmasttree(count):