A CSV extract stores every date as text, so the first job is typing the columns. pd.to_datetime turns text into dates you can subtract:
encounters["admit_date"] = pd.to_datetime(encounters["admit_date"])
encounters["discharge_date"] = pd.to_datetime(encounters["discharge_date"])
los = (encounters["discharge_date"] - encounters["admit_date"]).dt.days
Two dates subtract into a time span (a timedelta); .dt.days turns it into whole days. This course counts length of stay as discharge date minus admit date, so a same-day stay is 0 days. Never add 1.
A patient still in a bed has no discharge date. pandas reads the empty cell as a missing value (NaN, or NaT once the column holds dates), so .isna() finds the open stays and .notna() keeps the stays that ended.
Filter before you measure: encounters[encounters["encounter_type"] == "inpatient"]. Observation is a different status. For shares, value_counts(normalize=True) divides each count by the number of values it counted, leaving missing values out.