From ae726eda26382bb7c62f88e8d24c19769899b6de Mon Sep 17 00:00:00 2001 From: Sahib Bhai Date: Mon, 2 Sep 2024 16:27:46 -0700 Subject: [PATCH] Refactor code to rename 'Br/Ba' column to 'bedrooms_bathrooms' --- assets/datasets/buy.parquet | Bin 2060649 -> 2060758 bytes assets/javascript/popup.js | 2 +- buy_dataframe.py | 5 ++++- pages/buy_page.py | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/assets/datasets/buy.parquet b/assets/datasets/buy.parquet index f67ebb3c6164b7aacb32663c59fd46155d89f582..b978d74f66c8a3bcead0b43d67179ad327cccf3b 100644 GIT binary patch delta 2641 zcmaKs4Qx}_703Jh^6b!6#|jjbE)Iy9|XweylL zC6Me%N4odibI9=nB zkeT`y>>i_u>X(zN*k4Rnz+jZ#0QU8ySh_q$o64w@pq`*BRR>S3W@nyV4a*PEbyD{P zUCU5EhQ}xAwan;#9s9ZT!X$l~p)Nt!DZ29Blao63Jm^-J!Ld`c76yMvmqF5qDc?Co z@6u3zguS(79W!%9$DWW{rs-cPsQ2M|E%_RA@IxJYQfhgXevwif{uG+(NDXuAZ#wqq z7L1~5ZKGnIa9Q)eGweZ(l zOx;+jLMf#xRFD2e@x)>H50k%vxpZJF`<%on^DmUs2lw$$ugzb_Jo<7I`<_(2Hoxl? z>IZOQBdKCO{b(C|11@eP6JtBB=A+#!?YOFTl~U*6=qGAcHT`oRJN=OzdfrvPB<230 zZu+U>@t5GW(*^68spFmOi!iPyO;Y8L3SOSZEf@8qO7+PBfxR}h6W*|B>Y&De?XX5P zZ>p&Y_=bUeRdx8N$W9y);d>EWeo|hJ@76q%Pdx{!oTi4kG$XP%;i7>w!M;~%M#|C9fuR37zjc-Tm)m6tvf*+ZX6&+gao6mIenmsxBD5Ynv* zb_qzei{S~+uP53CbOO>@qhS9(o!SLl0&=-o!QRd#AeTm(UBD$Emz6Yo7n702XauCO zm}VD{2uR}YJaz$zfF$w?_D&LyEyf-odzkYs_V}f!(=NrE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5b;>d_)xKRJGU91E!7;rUszxTGyRIlo>%#tv93gO47cnuF4wkxZ)i)RMgi=|o?$!V1IG8@t)bBa(V$qUH+* z^&55YRl{w@I+npM=GFjzyAs;&;>|vbG$hj6wCtUvt-Kds)mrvWv_3rxDkP|yb?hvt zkf2(sV?PNfB%o-|djo|8RJD%13#RR#fRTL`Ku7=`*RuBjr)D-XNXSqh?nH*a7c5ls z$2mdbgqF|Z1c{T4T6PvENSu&&Cnx+pZ}wF^&b5O{^PJjbhi0a(@K4h4P<=xzF(6C* zsi-p0&|2S6u+i^;fcmZrj+B=le}pT1_z><7z$02`27exa4O)j^WxC<2-rx`uHb-AK zPDP;Bko06b&7MKL83jcz`^F+EKfc%t3rc##Pz067VA$9a2|2UjW{)Kr8p9_x!@|me zP;gL`Z3!tPk4O%@8iuW9)?h;FkTa3uzU3*Or7sm|5na9bO#u`yZZJ#XRby)aspiG%~WaI@!C~fmk81*t@yP*sy2~$PuTl zkbyJ(kTY6FM2jsGb=k~9ws3X0y9e}!+fG*)wwFaiEvc|Im=*8`5h^n&zdTzwXgFYr(A~T~09%b?X+e>wJHh0w_E#i7vT!C$7vxuhN$N#f2zv{7 zpj(0}d@l?MLy$`93uW-XF<4$vc#QiMO2DlWq>U~qG&bVimy7VE!DJEhB~Pv1mtN zRB#}*WAko{)al?8eFPd^Ra#8A*Sb4K5`s%kh>9~i&`o29Co@0^bTq3wk%_xg5m`+6 zhK1%eiO(eXgty1L!|Pa+ai`29`MG_e7P=B&Oj3ebu~|+F`8^%(Z0C@Bhqv2f-b)t@60%P-r=|Vc^c8!9;b18+)lH$^JI2p@UMfA)r7G>0WJF6T8?XU zDT9{(wS5F0_e=eCOnE;Q@~ZasM6wedoP#94-_!X kp(gXZKjlvQl})_*P6|XVlec*EY=eEJjPJhty7++Q|L?$cS^xk5 diff --git a/assets/javascript/popup.js b/assets/javascript/popup.js index 92b3a9e0..907f2671 100644 --- a/assets/javascript/popup.js +++ b/assets/javascript/popup.js @@ -243,7 +243,7 @@ window.dash_props = Object.assign({}, window.dash_props, { ${spaceRentBlock} Bedrooms/Bathrooms - ${data.bedrooms}/${data.bathrooms} + ${data.bedrooms_bathrooms} Year Built diff --git a/buy_dataframe.py b/buy_dataframe.py index d05bad26..f6a1e3c6 100644 --- a/buy_dataframe.py +++ b/buy_dataframe.py @@ -187,6 +187,9 @@ df['Half Bathrooms'] = (df['Br/Ba'].str.split('/', expand=True)[1]).str.split(',', expand=True)[2] df['Three Quarter Bathrooms'] = (df['Br/Ba'].str.split('/', expand=True)[1]).str.split(',', expand=True)[3] +# Rename the Br/Ba column to bedrooms_bathrooms +df.rename(columns={'Br/Ba': 'bedrooms_bathrooms'}, inplace=True) + # Convert a few columns into int64 # pd.to_numeric will convert into int64 or float64 automatically, which is cool # These columns are assumed to have NO MISSING DATA, so we can cast them as int64 instead of floats (ints can't handle NaNs) @@ -205,7 +208,7 @@ # Convert date_processed into DateTime df['date_processed'] = pd.to_datetime(df['date_processed'], errors='coerce', format='%Y-%m-%d') -cols = ['Full Bathrooms', 'Bedrooms', 'year_built', 'Sqft', 'list_price', 'Total Bathrooms', 'space_rent', 'ppsqft', 'hoa_fee'] +cols = ['Full Bathrooms', 'Bedrooms', 'year_built', 'Sqft', 'list_price', 'Total Bathrooms', 'space_rent', 'ppsqft', 'hoa_fee', 'bedrooms_bathrooms'] # Convert columns to string type for string operations df[cols] = df[cols].astype(str) # Remove commas and other non-numeric characters diff --git a/pages/buy_page.py b/pages/buy_page.py index 214e625c..2971398a 100644 --- a/pages/buy_page.py +++ b/pages/buy_page.py @@ -201,7 +201,7 @@ def update_map( lat=row.Latitude, lon=row.Longitude, data=dict( - #bedrooms_bathrooms=row['Br/Ba'], + bedrooms_bathrooms=row.bedrooms_bathrooms, #full_bathrooms=row['Full Bathrooms'], #half_bathrooms=row['Half Bathrooms'], #popup_html=row.popup_html,