Use better function names
This commit is contained in:
+4
-4
@@ -23,7 +23,7 @@ def _format_can_id(x):
|
|||||||
|
|
||||||
return s.upper()
|
return s.upper()
|
||||||
|
|
||||||
def calc_freq(df: pd.DataFrame) -> pd.DataFrame:
|
def calculate_frequency(df: pd.DataFrame) -> pd.DataFrame:
|
||||||
"""Calculates frequency counts and percentages for identifiers."""
|
"""Calculates frequency counts and percentages for identifiers."""
|
||||||
can_id_col = 'ID' if 'ID' in df.columns else 'Identifier'
|
can_id_col = 'ID' if 'ID' in df.columns else 'Identifier'
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ def calc_freq(df: pd.DataFrame) -> pd.DataFrame:
|
|||||||
freq_df['Percentage'] = (freq_df['Count'] / total * 100).round(2)
|
freq_df['Percentage'] = (freq_df['Count'] / total * 100).round(2)
|
||||||
return freq_df.sort_values('Count', ascending=True)
|
return freq_df.sort_values('Count', ascending=True)
|
||||||
|
|
||||||
def plot_freq(stats_df: pd.DataFrame, title: str) -> go.Figure:
|
def plot_frequency(stats_df: pd.DataFrame, title: str) -> go.Figure:
|
||||||
"""Generates interactive horizontal bar chart with log x-axis."""
|
"""Generates interactive horizontal bar chart with log x-axis."""
|
||||||
fig = px.bar(
|
fig = px.bar(
|
||||||
stats_df, y='Identifier', x='Count', orientation='h', title=title, log_x=True,
|
stats_df, y='Identifier', x='Count', orientation='h', title=title, log_x=True,
|
||||||
@@ -123,8 +123,8 @@ if __name__ == "__main__":
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
df = load_data(args.input)
|
df = load_data(args.input)
|
||||||
stats = calc_freq(df)
|
stats = calculate_frequency(df)
|
||||||
fig = plot_freq(stats, title=args.title)
|
fig = plot_frequency(stats, title=args.title)
|
||||||
config = {
|
config = {
|
||||||
'responsive': True,
|
'responsive': True,
|
||||||
'displaylogo': False,
|
'displaylogo': False,
|
||||||
|
|||||||
Reference in New Issue
Block a user