Skip to content

Commit ea41ee3

Browse files
committed
FIX: issues with code
1 parent b3474d1 commit ea41ee3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lectures/polars.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ optimized_query = (df_full.lazy()
596596
)
597597
598598
print("Optimized query plan:")
599-
print(optimized_query.describe_optimized_plan())
599+
print(optimized_query.explain())
600600
```
601601

602602
```{code-cell} ipython3
@@ -728,8 +728,8 @@ def read_data_polars(ticker_list,
728728
"""
729729
This function reads in closing price data from Yahoo
730730
for each tick in the ticker_list and returns a Polars DataFrame.
731+
Different indices may have different trading days, so we use joins to handle this.
731732
"""
732-
# Start with an empty list to collect DataFrames
733733
dataframes = []
734734
735735
for tick in ticker_list:
@@ -743,10 +743,12 @@ def read_data_polars(ticker_list,
743743
})
744744
dataframes.append(df)
745745
746-
# Join all DataFrames on the Date column
746+
# Start with the first DataFrame
747747
result = dataframes[0]
748+
749+
# Join additional DataFrames, handling mismatched dates with full outer join
748750
for df in dataframes[1:]:
749-
result = result.join(df, on='Date', how='outer')
751+
result = result.join(df, on='Date', how='full', coalesce=True)
750752
751753
return result
752754

0 commit comments

Comments
 (0)