Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import numpy as np
- df = pd.read_csv('data.csv')
- df
- count_unique = df['bedrooms'].nunique() # Apply unique function
- print(count_unique) # Print count of unique values
- count_unique = df['date'].nunique() # Apply unique function
- print(count_unique) # Print count of unique values
- df.columns
- # foematting dataset
- # Round off the column values to two decimal places in python pandas
- pd.options.display.float_format = '{:.2f}'.format
- print(df)
- df['bedrooms']=df['bedrooms'].astype(str) #changing the data type of the bedrooms columns to string
- after = df.dtypes
- after
- # identifying the missing values
- df.isnull().sum()
- # filling the missing value
- replace_median = df['floors'].median()
- print(replace_median)
- print(df['floors'].fillna(replace_median, inplace=True))
- # filling the missing value
- replace_mode = df['bedrooms'].mode()
- print(replace_mode)
- print(df['bedrooms'].fillna(replace_mode, inplace=True))
- empty_rows= df[df['date'].isna()]
- empty_rows
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement