<jupyter_start><jupyter_text>**1.Read the housingdata.csv file into pandas DataFrame and display first six rows of theDataFrame**<jupyter_code>from google.colab import files

uploadcsv = files.upload()
import numpy as np
import pandas as pd
df = pd.read_csv('housingdata.csv')
print(df)
df.head(6)<jupyter_output><empty_output><jupyter_text>**2.Display the column names and row index in separate cells.** Column Names<jupyter_code>df.columns<jupyter_output><empty_output><jupyter_text>Row Index<jupyter_code>row_index = df.index
for i in row_index:
  print(i)<jupyter_output>0
1
2
3
4
5
6
7
8<jupyter_text>**3.a) How many numbers of “STATE” exist in the dataset.Hint: use shape**<jupyter_code>states = df.STATE.shape[0]
print("Number of states in dataset are:",states)<jupyter_output>Number of states in dataset are: 9<jupyter_text>**b)How many unique states exist in the dataset**<jupyter_code>df.STATE.nunique() #STATE COLUMN UNIQUE VALUES<jupyter_output><empty_output><jupyter_text>**4.Retrieve the list of all NaN/Null/Empty cells in the form of Boolean list**<jupyter_code>df.isnull()<jupyter_output><empty_output><jupyter_text>**5.Drop all rows with N/A,NA,na values in Num_Bedrooms**<jupyter_code>df=df.dropna(subset=['NUM_BEDROOMS'])
df
df['NUM_BEDROOMS'] = df['NUM_BEDROOMS'].replace('na',np.nan)
df
df=df.dropna(subset=['NUM_BEDROOMS'])
df<jupyter_output><empty_output><jupyter_text>**6.Replace the NaN and String entries in Num_Bath with previous entry**<jupyter_code>df['NUM_BATH'] = df['NUM_BATH'].replace('HURLEY',np.nan)
df
df['NUM_BATH'].fillna(method='ffill',inplace=True)
df<jupyter_output>/usr/local/lib/python3.7/dist-packages/pandas/core/generic.py:6392: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  return self._update_inplace(result)<jupyter_text>**7.Replace the empty values in “SQ_FT” with the mean of the all entries.**<jupyter_code>df['SQ_FT'].mean()
df.dtypes
df['SQ_FT'] = df['SQ_FT'].replace('--', np.nan) 
df
df['SQ_FT']=pd.to_numeric(df['SQ_FT'])
df.dtypes
df['SQ_FT'].fillna(value= df['SQ_FT'].mean(), inplace=True)
df<jupyter_output>/usr/local/lib/python3.7/dist-packages/pandas/core/generic.py:6392: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  return self._update_inplace(result)<jupyter_text>**8.What is the sum of SQ_FT of all entries in the dataset.**<jupyter_code>print('Sum of SQ_FT of all entries in dataset: ',df['SQ_FT'].sum())<jupyter_output>Sum of SQ_FT of all entries in dataset:  6375.0<jupyter_text>**9.Add a new column “NUM_STORE” and with all the values as 1 for all rows**<jupyter_code>df['NUM_STORE'] = [1 for i in range(len(df))]
df<jupyter_output>/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:1: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  """Entry point for launching an IPython kernel.<jupyter_text>**10.Create a DataFrame containing all entries of TN state only**<jupyter_code>df1 = df[df['STATE'] == 'TN'] 
df1<jupyter_output><empty_output><jupyter_text>**11.Create a DataFrame having SQ_FT area greater than 1000 and display the DataFrame**<jupyter_code>df2 = df[df['SQ_FT']>1000] 
print(df2)<jupyter_output>PID        STATE      PRICE NUM_BEDROOMS NUM_BATH   SQ_FT  \
1  100002000.0  MAHARASHTRA      21325            3      1.5  1062.5   
4          NaN           TN  589465645            3        2  1600.0   
7  100008000.0           HP      23131            1        1  1062.5   

   NUM_STORE  
1          1  
4          1  
7          1<jupyter_text>**12.Create a DataFrame having only first Three columns and First Three rows**<jupyter_code>df3 = df.iloc[0:3,0:3] 
df3<jupyter_output><empty_output><jupyter_text>**13.Display the state having highest average price per square foot of housing area.Hint: Average of (TotalPrice/Sq_Ft)**<jupyter_code>averageprice = list(map(lambda x,y: x/y,df['PRICE'],df['SQ_FT']))
print(averageprice)
df['STATE'][averageprice.index(max(averageprice))]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1248339973439575, 'fraction_numerical': 0.030765825586542717, 'mean_word_length': 5.276388888888889, 'pattern_counts': {'":': 0, '<': 54, '<?xml version=': 0, '>': 55, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '15', 'dir': 'jupyter-structured-clean-dedup', 'id': '286886', 'license': 'MIT', 'n_tokens_mistral': 1770, 'n_tokens_neox': 1673, 'n_words': 381, 'path': 'Avula_Girish_Kumar_21-24-04/Assn3_Avula_Girish_Kumar_21_24_04.ipynb', 'repo_name': 'girishkumar-1997/Avula_Girish_Kumar_21-24-04', 'size': '4518'}