Skip to content

Commit

Permalink
fix(append-upgrade): upgrade pandas .append
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Aug 26, 2024
1 parent bf92aea commit ff9a03d
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions osmsg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def create_charts(df, fname):
other_editors_count = grouped_editors.iloc[num_categories:].sum()

# Create a new series with the top categories and "others" count
editors_data = top_editors.append(
editors_data = top_editors._append(
pd.Series(other_editors_count, index=["Others"])
)

Expand Down Expand Up @@ -450,7 +450,7 @@ def create_charts(df, fname):
# ax.set_yscale("log")
ax.yaxis.set_major_formatter(ticker.StrMethodFormatter("{x:,.0f}"))
plt.savefig(f"{fname}_tags.png", bbox_inches="tight")
created_charts.append(f"{fname}_tags.png")
created_charts._append(f"{fname}_tags.png")

return created_charts

Expand Down Expand Up @@ -528,12 +528,16 @@ def update_stats(df1, df2):
# Iterate over the integer columns and update the values
for col in int_cols:
merged_df[col] = merged_df.apply(
lambda row: pd.to_numeric(row[f"{col}_x"], errors="coerce")
+ pd.to_numeric(row[f"{col}_y"], errors="coerce")
if pd.notnull(row[f"{col}_x"]) and pd.notnull(row[f"{col}_y"])
else pd.to_numeric(row[f"{col}_x"], errors="coerce") or 0
if pd.notnull(row[f"{col}_x"])
else pd.to_numeric(row[f"{col}_y"], errors="coerce") or 0,
lambda row: (
pd.to_numeric(row[f"{col}_x"], errors="coerce")
+ pd.to_numeric(row[f"{col}_y"], errors="coerce")
if pd.notnull(row[f"{col}_x"]) and pd.notnull(row[f"{col}_y"])
else (
pd.to_numeric(row[f"{col}_x"], errors="coerce") or 0
if pd.notnull(row[f"{col}_x"])
else pd.to_numeric(row[f"{col}_y"], errors="coerce") or 0
)
),
axis=1,
)

Expand Down Expand Up @@ -641,12 +645,16 @@ def update_summary(df1, df2):
# Iterate over the integer columns and update the values
for col in int_cols:
merged_df[col] = merged_df.apply(
lambda row: pd.to_numeric(row[f"{col}_x"], errors="coerce")
+ pd.to_numeric(row[f"{col}_y"], errors="coerce")
if pd.notnull(row[f"{col}_x"]) and pd.notnull(row[f"{col}_y"])
else pd.to_numeric(row[f"{col}_x"], errors="coerce") or 0
if pd.notnull(row[f"{col}_x"])
else pd.to_numeric(row[f"{col}_y"], errors="coerce") or 0,
lambda row: (
pd.to_numeric(row[f"{col}_x"], errors="coerce")
+ pd.to_numeric(row[f"{col}_y"], errors="coerce")
if pd.notnull(row[f"{col}_x"]) and pd.notnull(row[f"{col}_y"])
else (
pd.to_numeric(row[f"{col}_x"], errors="coerce") or 0
if pd.notnull(row[f"{col}_x"])
else pd.to_numeric(row[f"{col}_y"], errors="coerce") or 0
)
),
axis=1,
)
if "editors" in df1.columns:
Expand Down

0 comments on commit ff9a03d

Please sign in to comment.