Data Analytics Codes
Klausur
Klausur
-
- 1 / 65
-
Lernkarten
What is the Python code to rescale two variables to the interval [0,1]?
Res_df = (Data_a - Data_a.min()) / (Data_a.max() - Data_a.min())
What is the Python code to standardize two variables?
Data_a = pd.DataFrame({"Age": [10,20,30], "Income": [30,40,50]})norm_df = (Data_a - Data_a.mean()) / Data_a.std()
What is the Python code to read the data from a table?
Data_a = pd.DataFrame({"Age": [10,20,30], "Income": [30,40,50]})
What is the Python code to oversample houses with more than 12 rooms?
weights = [0.9 if rooms > 12 else 0.01 for rooms in housing_df.ROOMS]
Sample_2 = housing_df.sample(10, weights=weights, random_state=1)
Sample_2
What is the Python code to draw a random sample of 10 houses from the dataset?
Sample_1 = housing_df.sample(10, random_state=1) Sample_1
What is the Python code to calculate the median?
housing_df.VARIABLE.median()
What is the Python code to calculate the arithmetic mean?
housing_df.VARIABLE.mean()
Rename all column names in Python so that the spaces contained are replaced by _.
housing_df.columns = [s.strip().replace(" ", "_") for s in housing_df.columns]
What is the Python code to load a dataset and assign a name for the dataframe in pandas?
dataframename_df = pd.read_csv("dataset.csv", keep_default_na=False)
What is the Python code for frequency tables?
pd.crosstab(housing_df["CHAS"], housing_df["CAT_MEDV"])
What is the Python code of a line chart using matplotlib?
sns.lineplot(x="Date", y="Ridership", data=trains_df)
What is the Python code for a bar chart representing the median using seaborn?
from numpy import median sns.barplot(x="CHAS", y="MEDV", data=housing_df, estimator=median)
What is the Python code for a bar chart representing the arithmetic mean using seaborn?
from numpy import mean sns.barplot(x="CHAS", y="MEDV", data=housing_df, estimator=mean)
What is the Python code for a bar chart using seaborn?
sns.countplot(x="CHAS", data=housing_df)
What is the Python code for a histogram using seaborn?
sns.histplot(data=housing_df, x="MEDV")
Visualization of the distribution of a continuous variable.
What is the Python code for grouped boxplots using seaborn?
sns.boxplot(y=housing_df["MEDV"], x=housing_df["CHAS"], whis=[0,100])
What is the Python code for boxplots using seaborn?
sns.boxplot(y=housing_df["MEDV"], whis=[0,100])
What is the Python code for the correlation matrix?
housing_df.corr().round(2)
What is the Python code for the scatter plot matrix in Python using seaborn?
sns.pairplot(housing_df[['CRIM', 'INDUS', 'LSTAT', 'MEDV']])
What is the code of rescale in Python?
res_bed = (housing_df["BEDROOMS"] - housing_df["BEDROOMS"].min()) / (housing_df["BEDROOMS"].max() - housing_df["BEDROOMS"].min()) res_bed.describe()
What is the code of standardisation in Python?
norm_df = (housing_df - housing_df.mean()) / housing_df.std() norm_df.describe()
What is the code to show the first 5 lines of the dataset?
housing_df.head()
What is the code to show the dimension of the dataset?
housing_df.shape
What is the code for descriptive analysis of the dataset housing?
housing_df.describe()