Data Visualizations 7

1. If we create a DataFrame, each of the column inside of it is already a set of Series. Does not necessary to change them into a one-column Dataframe.

2. Here we use scatter_matrix function to plot the DataFrame:

  normal_movies = hollywood_movies[hollywood_movies["Film"] != "Paranormal Activity"]

  from pandas.tools.plotting import scatter_matrix #import scatter_matrix function from pandas.tool.plotting

  scatter_matrix(normal_movies[["Profitability","Audience Rating"]],figsize = (6,6)) #If we only put two columns into the scatter_matrix, we will get 4 plotting inside of the figure. it is a vs a, a vs b, b vs a, b vs b. a = "Profitability",     b = "Audience Rating".

3. In the following code, we plot cirtic rating and audience rating compare to a range which is generate automatically.

  normal_movies[["Critic Rating","Audience Rating"]].plot(kind = "box")

4.While we use seaborn.boxplot function, here is the example.

  normal_movies = normal_movies.sort_values("Year")

  fig = plt.figure(figsize=(8,4))

  yr1 = fig.add_subplot(1,2,1)
  yr2 = fig.add_subplot(1,2,2)

  sns.boxplot(x=normal_movies["Year"], y=normal_movies["Critic Rating"],ax = yr1)
  sns.boxplot(x=normal_movies["Year"], y=normal_movies["Audience Rating"],ax = yr2)
  plt.show()

output:

  

5.

Another way of using boxplot:

  normal_movies[‘Profitable‘]= normal_movies["Profitability"] >= 1
  fig = plt.figure(figsize = (12,6))
  ax1 = fig.add_subplot(1,2,1)
  ax2 = fig.add_subplot(1,2,2)
  sns.boxplot(data = normal_movies, x="Profitable",y ="Audience Rating",ax = ax1)
  sns.boxplot(data = normal_movies, x="Profitable",y ="Critic Rating",ax = ax2)

时间: 2024-08-06 15:34:57

Data Visualizations 7的相关文章

Data Visualizations 6

Visualize Geographic Data: To deal with mutiple DataFrame 1. How to install a library into the Anaconda: In Jupyter Notebook, under tag Conda, we can install packages and save them into Anaconda > Lib > site-packages folder 2. Create a basemap insta

Data Visualizations 2

1.Histogram : A histogram is a graph that enables you to visualize the distribution of values of a column. Example: import matplotlib.pyplot as plt columns = ['Median','Sample_size'] recent_grads.hist(column=columns)# to visulize the column "Median&q

Data Visualizations 1

1.Independent variables : each variable is saperate from others in the dataset. 2.Data scatter: weight = [600,150,200,300,200,100,125,180] height = [60,65,73,70,65,58,66,67] # dataset import matplotlib.pyplot as plt # import pyplot from matplotlib pl

Data Visualizations 3

Data Cleaning and visualization: 1.Before cleaning a set of data, we need to inspect the data by using shape(),head(),dtype(),decribe() function. 2.First, we are going to deal with the missing data.(by using dropna() or loc[]) 3.Second, we are going

Data Visualizations 4

So far, I have learn some types of plotting methods: Matplotlib's high-level plotting methods - e.g. .scatter(), .plot() Seaborn's high-level plotting methods - e.g. .distplot(), .boxplot() Pandas DataFrame methods - e.g. .hist(), .boxplot() High lev

Data Visualizations 5

To genereate a bar chart with matplotlib: ////////////////////////////////Import libraries and classes///////////////////////////////////////////////////////////////////// import pandas as pd import matplotlib.pyplot as plt import seaborn as sns impo

R8:Learning paths for Data Science[continuous updating…]

Comprehensive learning path – Data Science in Python Journey from a Python noob to a Kaggler on Python So, you want to become a data scientist or may be you are already one and want to expand your tool repository. You have landed at the right place.

data cleaning

Cleaning data in Python Table of Contents Set up environments Data analysis packages in Python Clean data in Python Load dataset into Spyder Subset Drop data Transform data Create new variables Rename variables Merge two datasets Handle missing value

7 Tools for Data Visualization in R, Python, and Julia

7 Tools for Data Visualization in R, Python, and Julia Last week, some examples of creating visualizations with htmlwidgets and R were presented. Fortunately, there are many more options available for creating nice visualizations. Tools and libraries