Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use map instead of applymap #330

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lectures/inflation_history.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ def process_df(df):
# Handle duplicates by keeping the first
df = df[~df.index.duplicated(keep='first')]

# Convert attribute values to numeric
df = df.applymap(lambda x: float(x) \
# convert attribute values to numeric
mmcky marked this conversation as resolved.
Show resolved Hide resolved
df = df.map(lambda x: float(x) \
if x != '—' else np.nan)

# Finally, we only focus on data between 1919 and 1925
Expand Down Expand Up @@ -367,7 +367,7 @@ for i in range(4):
# Apply process_entry on the selected sheet
sheet_list = [
pd.read_excel(xls, 'Table3.' + str(ind),
header=1).iloc[:row].applymap(process_entry)
header=1).iloc[:row].map(process_entry)
for ind, row in zip(indices, rows)]

sheet_list = [process_df(df) for df in sheet_list]
Expand Down
Loading