Python酷库之旅-第三方库Pandas(090)

news2025/2/5 11:00:09

目录

一、用法精讲

381、pandas.Series.plot方法

381-1、语法

381-2、参数

381-3、功能

381-4、返回值

381-5、说明

381-6、用法

381-6-1、数据准备

381-6-2、代码示例

381-6-3、结果输出

382、 pandas.Series.plot.area方法

382-1、语法

382-2、参数

382-3、功能

382-4、返回值

382-5、说明

382-6、用法

382-6-1、数据准备

382-6-2、代码示例

382-6-3、结果输出

383、pandas.Series.plot.bar方法

383-1、语法

383-2、参数

383-3、功能

383-4、返回值

383-5、说明

383-6、用法

383-6-1、数据准备

383-6-2、代码示例

383-6-3、结果输出

384、pandas.Series.plot.barh方法

384-1、语法

384-2、参数

384-3、功能

384-4、返回值

384-5、说明

384-6、用法

384-6-1、数据准备

384-6-2、代码示例

384-6-3、结果输出

385、pandas.Series.plot.box方法

385-1、语法

385-2、参数

385-3、功能

385-4、返回值

385-5、说明

385-6、用法

385-6-1、数据准备

385-6-2、代码示例

385-6-3、结果输出

二、推荐阅读

1、Python筑基之旅

2、Python函数之旅

3、Python算法之旅

4、Python魔法之旅

5、博客个人主页

一、用法精讲

381、pandas.Series.plot方法
381-1、语法
# 381、pandas.Series.plot方法
pandas.Series.plot(*args, **kwargs)
Make plots of Series or DataFrame.

Uses the backend specified by the option plotting.backend. By default, matplotlib is used.

Parameters:
dataSeries or DataFrame
The object for which the method is called.

xlabel or position, default None
Only used if data is a DataFrame.

ylabel, position or list of label, positions, default None
Allows plotting of one column versus another. Only used if data is a DataFrame.

kindstr
The kind of plot to produce:

‘line’ : line plot (default)

‘bar’ : vertical bar plot

‘barh’ : horizontal bar plot

‘hist’ : histogram

‘box’ : boxplot

‘kde’ : Kernel Density Estimation plot

‘density’ : same as ‘kde’

‘area’ : area plot

‘pie’ : pie plot

‘scatter’ : scatter plot (DataFrame only)

‘hexbin’ : hexbin plot (DataFrame only)

axmatplotlib axes object, default None
An axes of the current figure.

subplotsbool or sequence of iterables, default False
Whether to group columns into subplots:

False : No subplots will be used

True : Make separate subplots for each column.

sequence of iterables of column labels: Create a subplot for each group of columns. For example [(‘a’, ‘c’), (‘b’, ‘d’)] will create 2 subplots: one with columns ‘a’ and ‘c’, and one with columns ‘b’ and ‘d’. Remaining columns that aren’t specified will be plotted in additional subplots (one per column).

New in version 1.5.0.

sharexbool, default True if ax is None else False
In case subplots=True, share x axis and set some x axis labels to invisible; defaults to True if ax is None otherwise False if an ax is passed in; Be aware, that passing in both an ax and sharex=True will alter all x axis labels for all axis in a figure.

shareybool, default False
In case subplots=True, share y axis and set some y axis labels to invisible.

layouttuple, optional
(rows, columns) for the layout of subplots.

figsizea tuple (width, height) in inches
Size of a figure object.

use_indexbool, default True
Use index as ticks for x axis.

titlestr or list
Title to use for the plot. If a string is passed, print the string at the top of the figure. If a list is passed and subplots is True, print each item in the list above the corresponding subplot.

gridbool, default None (matlab style default)
Axis grid lines.

legendbool or {‘reverse’}
Place legend on axis subplots.

stylelist or dict
The matplotlib line style per column.

logxbool or ‘sym’, default False
Use log scaling or symlog scaling on x axis.

logybool or ‘sym’ default False
Use log scaling or symlog scaling on y axis.

loglogbool or ‘sym’, default False
Use log scaling or symlog scaling on both x and y axes.

xtickssequence
Values to use for the xticks.

ytickssequence
Values to use for the yticks.

xlim2-tuple/list
Set the x limits of the current axes.

ylim2-tuple/list
Set the y limits of the current axes.

xlabellabel, optional
Name to use for the xlabel on x-axis. Default uses index name as xlabel, or the x-column name for planar plots.

Changed in version 2.0.0: Now applicable to histograms.

ylabellabel, optional
Name to use for the ylabel on y-axis. Default will show no ylabel, or the y-column name for planar plots.

Changed in version 2.0.0: Now applicable to histograms.

rotfloat, default None
Rotation for ticks (xticks for vertical, yticks for horizontal plots).

fontsizefloat, default None
Font size for xticks and yticks.

colormapstr or matplotlib colormap object, default None
Colormap to select colors from. If string, load colormap with that name from matplotlib.

colorbarbool, optional
If True, plot colorbar (only relevant for ‘scatter’ and ‘hexbin’ plots).

positionfloat
Specify relative alignments for bar plot layout. From 0 (left/bottom-end) to 1 (right/top-end). Default is 0.5 (center).

tablebool, Series or DataFrame, default False
If True, draw a table using the data in the DataFrame and the data will be transposed to meet matplotlib’s default layout. If a Series or DataFrame is passed, use passed data to draw a table.

yerrDataFrame, Series, array-like, dict and str
See Plotting with Error Bars for detail.

xerrDataFrame, Series, array-like, dict and str
Equivalent to yerr.

stackedbool, default False in line and bar plots, and True in area plot
If True, create stacked plot.

secondary_ybool or sequence, default False
Whether to plot on the secondary y-axis if a list/tuple, which columns to plot on secondary y-axis.

mark_rightbool, default True
When using a secondary_y axis, automatically mark the column labels with “(right)” in the legend.

include_boolbool, default is False
If True, boolean values can be plotted.

backendstr, default None
Backend to use instead of the backend specified in the option plotting.backend. For instance, ‘matplotlib’. Alternatively, to specify the plotting.backend for the whole session, set pd.options.plotting.backend.

**kwargs
Options to pass to matplotlib plotting method.

Returns:
matplotlib.axes.Axes
or numpy.ndarray of them
If the backend is not the default matplotlib one, the return value will be the object returned by the backend.

Notes

See matplotlib documentation online for more on this subject

If kind = ‘bar’ or ‘barh’, you can specify relative alignments for bar plot layout by position keyword. From 0 (left/bottom-end) to 1 (right/top-end). Default is 0.5 (center)
381-2、参数

381-2-1、kind(可选,默认值为'line')字符串,指定图表的类型,可选值有:'line'、'bar'、'barh'、'hist'、'box'、'kde'、'density'、'area'、'pie'等。

381-2-2、ax(可选,默认值为None)matplotlib.axes.Axes,用于绘制图形的Axes对象,如果未提供,则会自动创建一个新的图形。

381-2-3、subplots(可选,默认值为False)布尔值,是否为每个变量创建一个子图,如果是True,则每个要绘制的变量将会在一个新的子图中展现。

381-2-4、sharex(可选,默认值为False)布尔值,如果subplots=True,是否共享x轴。

381-2-5、sharey(可选,默认值为False)布尔值,如果subplots=True,是否共享y轴。

381-2-6、layout(可选)元组,用于指定子图的排布方式,例如(rows,cols)。

381-2-7、figsize(可选)元组,确定图形的大小,单位为英寸。例如(10,5)表示宽10英寸,高5英寸。

381-2-8、title(可选)字符串,图形的标题。

381-2-9、grid(可选,默认值为False)布尔值,是否显示网格线。

381-2-10、legend(可选,默认值为False)布尔值,是否显示图例。

381-2-11、color(可选)字符串或列表,指定图形的颜色,可以是单个颜色或颜色列表。

381-2-12、fontsize(可选)整数,指定字体大小。

381-2-13、xlabel(可选)字符串,x轴的标签。

381-2-14、ylabel(可选)字符串,y轴的标签。

381-2-15、xlim(可选)元组,设置x轴的范围。

381-2-16、ylim(可选)元组,设置y轴的范围。

381-2-17、other kwargs(可选)其他可选参数会被传递给Matplotlib的绘图函数。

381-3、功能

        通过该方法,用户可以快速、简便地可视化时间序列数据、分布以及不同类型的统计信息等,相比于直接使用Matplotlib进行绘图,使用pandas的绘图接口可以更高效地处理Series数据。

381-4、返回值

        返回一个matplotlib.axes.Axes对象,表示绘图区域,用户可以利用该对象进一步定制图形,例如添加注释、修改图例等。

381-5、说明

        使用场景:

381-5-1、时间序列分析:当需要分析时间序列数据时,可以使用plot方法绘制时间序列图,帮助识别趋势、周期和异常值。

381-5-2、数据分布检视:利用直方图(hist)和密度图(kde)对数据进行分布分析,了解数据的集中趋势和离散程度。

381-5-3、比较不同变量:当需要比较多个变量的值时,可以通过绘制条形图(bar)或水平条形图 (barh)来直观展示不同变量之间的关系。

381-5-4、统计分析:使用箱线图(box)进行统计描述,帮助识别数据的四分位数、极值和异常值。

381-5-5、探索性数据分析(EDA):在进行数据清洗和初步分析时,通过可视化手段快速理解数据的特征和分布,为后续的数据处理和建模提供依据。

381-5-6、报告和展示:在制作数据报告或展示时,通过图表能够以更加直观的方式呈现数据结果,帮助听众理解复杂信息。

381-5-7、分析不同组的特征:针对不同分组的数据,通过绘图可以清晰地展示各组之间的差异,例如,通过分组绘制多个条形图进行比较。

381-5-8、自定义可视化:对于需要特定样式或自定义效果的用户,该方法允许传入丰富的参数,使用户可以调整颜色、标签、网格等,提升图表的美观性和可读性。

381-6、用法
381-6-1、数据准备
381-6-2、代码示例
# 381、pandas.Series.plot方法
# 381-1、时间序列分析
import pandas as pd
import matplotlib.pyplot as plt
# 创建时间序列数据
date_range = pd.date_range(start='2024-01-01', periods=100)
data = pd.Series(range(100), index=date_range)
# 绘制时间序列图
data.plot(title='Time Series Data', xlabel='Date', ylabel='Value')
plt.show()

# 381-2、数据分布检视
import pandas as pd
import numpy as np
# 生成随机数据
data = pd.Series(np.random.randn(1000))
# 绘制直方图
data.plot(kind='hist', bins=30, title='Histogram', xlabel='Value', ylabel='Frequency', color='purple')
plt.show()
# 绘制密度图
data.plot(kind='kde', title='Density Plot', xlabel='Value', ylabel='Density', color='purple')
plt.show()

# 381-3、比较不同变量
import pandas as pd
# 创建两个变量的数据
data1 = pd.Series([3, 7, 5, 11], index=['A', 'B', 'C', 'D'])
data2 = pd.Series([2, 5, 8, 12], index=['A', 'B', 'C', 'D'])
# 合并数据
combined_data = pd.DataFrame({'Data1': data1, 'Data2': data2})
# 绘制条形图
combined_data.plot(kind='bar', title='Comparison of Two Datasets', ylabel='Values')
plt.xticks(rotation=0)
plt.show()

# 381-4、统计分析
import pandas as pd
# 随机生成数据
data = pd.Series(np.random.randn(100))
# 绘制箱线图
data.plot(kind='box', title='Box Plot', ylabel='Value')
plt.show()

# 381-5、探索性数据分析(EDA)
import pandas as pd
# 生成一组示例数据
data = pd.Series([4, 2, 3, 4, 3, 7, 4, 5, 6, 7, 8, 9, 8])
# 绘制直方图
data.plot(kind='hist', bins=10, title='Exploratory Data Analysis', xlabel='Value', ylabel='Frequency', color='green')
plt.show()

# 381-6、自定义可视化
import pandas as pd
# 生成数据
data = pd.Series([10, 20, 15, 25], index=['Q1', 'Q2', 'Q3', 'Q4'])
# 绘制条形图并自定义样式
data.plot(kind='barh', color='purple', title='Custom Bar Plot', ylabel='Sales', edgecolor='black')
plt.xticks(rotation=0)
plt.grid(axis='y')
plt.show()

# 381-7、分析不同组的特征
import pandas as pd
# 创建分类数据
group_labels = ['A', 'A', 'B', 'B', 'C', 'C']
data = pd.Series([1, 2, 3, 4, 5, 6], index=group_labels)
# 按组绘制条形图
data.groupby(data.index).sum().plot(kind='bar', title='Group Comparison', ylabel='Sum', color='green')
plt.xticks(rotation=0)
plt.show()
381-6-3、结果输出
# 381、pandas.Series.plot方法
# 381-1、时间序列分析
# 见图1

# 381-2、数据分布检视
# 见图2

# 381-3、比较不同变量
# 见图3

# 381-4、统计分析
# 见图4

# 381-5、探索性数据分析(EDA)
# 见图5

# 381-6、自定义可视化
# 见图6

# 381-7、分析不同组的特征
# 见图7

图1:

 

图2:

 

 

图3:

 

图4:

 

图5:

 

图6:

 

图7:

 

382、 pandas.Series.plot.area方法
382-1、语法
# 382、 pandas.Series.plot.area方法
pandas.Series.plot.area(x=None, y=None, stacked=True, **kwargs)
Draw a stacked area plot.

An area plot displays quantitative data visually. This function wraps the matplotlib area function.

Parameters:
x
label or position, optional
Coordinates for the X axis. By default uses the index.

y
label or position, optional
Column to plot. By default uses all columns.

stacked
bool, default True
Area plots are stacked by default. Set to False to create a unstacked plot.

**kwargs
Additional keyword arguments are documented in DataFrame.plot().

Returns:
matplotlib.axes.Axes or numpy.ndarray
Area plot, or array of area plots if subplots is True.
382-2、参数

382-2-1、x(可选,默认值为None)字符串或None,指定用作横坐标的列名,如果没有提供,默认使用Series的索引。

382-2-2、y(可选,默认值为None)字符串或None,指定用作纵坐标的列名,对于Series类型,通常不需要指定,因为它会默认为Series的值。

382-2-3、stacked(可选,默认值为True)布尔值,如果为True,则绘制堆叠面积图;如果为False,则绘制分开的面积图,这对于观察组成部分相对总量的变化非常有用。

382-2-4、**kwargs(可选)其他可选参数,如图形的样式、颜色、标签等,具体可以与matplotlib的绘图函数兼容。

382-3、功能

        用于绘制面积图,使得可视化的数据更为直观,能够直观地展示数据随时间或其他变量的变化,并且可以根据stacked参数设置是否堆叠显示,适合于呈现组成部分对总量变化的贡献或比较不同组别之间的面积。

382-4、返回值

        返回一个matplotlib.axes.Axes对象,允许对生成的图形进行进一步的自定义和调整。

382-5、说明

        使用场景:

382-5-1、时间序列数据分析:对于随时间变化的数据(如销售额、气温等),面积图可以有效地展示每个时间点的总值以及各个组成部分的变化,帮助分析趋势和季节性影响。

382-5-2、组成部分展示:面积图可以用来展示不同类别或组成部分在总量中的占比,例如,显示不同产品在总销售额中的贡献,便于识别主要产品及其变化趋势。

382-5-3、堆叠信息对比:当需要比较多个类别的数据时,堆叠面积图可以同时显示各类别的变化,并提供直观的总量理解,帮助识别出哪一部分对整体变化影响最大。

382-5-4、市场份额分析:在市场研究中,可以使用面积图来显示不同公司或品牌的市场份额随时间变化的趋势,清楚地反映竞争态势。

382-5-5、展示不同变量的关系:在数据科学和统计分析中,可以利用面积图来展示多个变量之间的关系,比如资源消耗、产出等的相对变化,帮助快速识别潜在的关联性。

382-5-6、教育与展示:在教学中,利用面积图能够帮助学生更好地理解和掌握数据的变化关系及统计分析结果,是一种有效的可视化工具。

382-6、用法
382-6-1、数据准备
382-6-2、代码示例
# 382、pandas.Series.plot.area方法
# 382-1、时间序列数据分析
import pandas as pd
import matplotlib.pyplot as plt
# 创建时间序列数据
date_range = pd.date_range(start='2023-01-01', periods=12, freq='ME')
data = pd.Series([100, 120, 150, 170, 160, 180, 200, 220, 240, 250, 280, 300], index=date_range)
# 绘制面积图
data.plot.area(title='Monthly Sales Over a Year', figsize=(10, 6), alpha=0.5, color='green')
plt.ylabel('Sales')
plt.xlabel('Date')
plt.grid(False)
plt.show()

# 382-2、组成部分展示
import pandas as pd
import matplotlib.pyplot as plt
# 创建各产品的月销售数据
data = {
    'Product A': [40, 50, 60, 70, 80, 90],
    'Product B': [30, 40, 50, 55, 60, 80],
    'Product C': [20, 30, 40, 60, 80, 100]
}
index = pd.date_range(start='2023-01-01', periods=6, freq='ME')
df = pd.DataFrame(data, index=index)
# 绘制堆叠面积图
df.plot.area(title='Product Sales Contribution', figsize=(10, 6), alpha=0.6)
plt.ylabel('Sales')
plt.xlabel('Month')
plt.grid(True)
plt.show()

# 382-3、堆叠信息对比
import pandas as pd
import matplotlib.pyplot as plt
# 创建多个分类的数据
data = {
    'Category 1': [3, 5, 2, 4],
    'Category 2': [2, 2, 5, 3],
    'Category 3': [4, 3, 4, 1]
}
index = ['Q1', 'Q2', 'Q3', 'Q4']
df = pd.DataFrame(data, index=index)
# 绘制堆叠面积图
df.plot.area(title='Quarterly Category Comparison', figsize=(10, 6), alpha=0.7)
plt.ylabel('Values')
plt.xlabel('Quarter')
plt.grid(True)
plt.show()

# 382-4、市场份额分析
import pandas as pd
import matplotlib.pyplot as plt
# 创建品牌的市场份额数据
data = {
    'Brand A': [30, 35, 40, 50],
    'Brand B': [25, 20, 15, 10],
    'Brand C': [20, 25, 30, 35]
}
index = ['2020', '2021', '2022', '2023']
df = pd.DataFrame(data, index=index)
# 绘制面积图
df.plot.area(title='Market Share Analysis', figsize=(10, 6), alpha=0.5)
plt.ylabel('Market Share (%)')
plt.xlabel('Year')
plt.grid(True)
plt.show()

# 382-5、展示不同变量的关系
import pandas as pd
import matplotlib.pyplot as plt
# 创建资源消耗的数据
data = {
    'Resource A': [200, 220, 240, 260],
    'Resource B': [150, 180, 210, 240],
    'Resource C': [100, 130, 150, 180]
}
index = ['2020', '2021', '2022', '2023']
df = pd.DataFrame(data, index=index)
# 绘制面积图
df.plot.area(title='Resource Consumption Comparison', figsize=(10, 6), alpha=0.6)
plt.ylabel('Consumption')
plt.xlabel('Year')
plt.grid(True)
plt.show()

# 382-6、教育与展示
import pandas as pd
import matplotlib.pyplot as plt
# 学生成绩数据
data = {
    'Math': [85, 90, 78, 92, 88],
    'Science': [79, 88, 82, 85, 90],
    'English': [90, 85, 88, 92, 95]
}
index = ['Student 1', 'Student 2', 'Student 3', 'Student 4', 'Student 5']
df = pd.DataFrame(data, index=index)
# 绘制堆叠面积图
df.plot.area(title='Student Grades in Subjects', figsize=(10, 6), alpha=0.7)
plt.ylabel('Grades')
plt.xlabel('Students')
plt.grid(True)
plt.show()
382-6-3、结果输出
# 382、pandas.Series.plot.area方法
# 382-1、时间序列数据分析
# 见图8

# 382-2、组成部分展示
# 见图9

# 382-3、堆叠信息对比
# 见图10

# 382-4、市场份额分析
# 见图11

# 382-5、展示不同变量的关系
# 见图12

# 382-6、教育与展示
# 见图13

图8:

 

图9:

 

图10:

 

图11:

 

图12:

 

图13:

 

383、pandas.Series.plot.bar方法
383-1、语法
# 383、pandas.Series.plot.bar方法
pandas.Series.plot.bar(x=None, y=None, **kwargs)
Vertical bar plot.

A bar plot is a plot that presents categorical data with rectangular bars with lengths proportional to the values that they represent. A bar plot shows comparisons among discrete categories. One axis of the plot shows the specific categories being compared, and the other axis represents a measured value.

Parameters:
x
label or position, optional
Allows plotting of one column versus another. If not specified, the index of the DataFrame is used.

y
label or position, optional
Allows plotting of one column versus another. If not specified, all numerical columns are used.

color
str, array-like, or dict, optional
The color for each of the DataFrame’s columns. Possible values are:

A single color string referred to by name, RGB or RGBA code,
for instance ‘red’ or ‘#a98d19’.

A sequence of color strings referred to by name, RGB or RGBA
code, which will be used for each column recursively. For instance [‘green’,’yellow’] each column’s bar will be filled in green or yellow, alternatively. If there is only a single column to be plotted, then only the first color from the color list will be used.

A dict of the form {column namecolor}, so that each column will be
colored accordingly. For example, if your columns are called a and b, then passing {‘a’: ‘green’, ‘b’: ‘red’} will color bars for column a in green and bars for column b in red.

**kwargs
Additional keyword arguments are documented in DataFrame.plot().

Returns:
matplotlib.axes.Axes or np.ndarray of them
An ndarray is returned with one matplotlib.axes.Axes per column when subplots=True.
383-2、参数

383-2-1、x(可选,默认值为None)字符串或None,指定条形图的 x 轴数据,如果未提供,默认使用Series的索引作为 x 轴。

383-2-2、y(可选,默认值为None)字符串或None,指定y轴数据,如果你在Series中提供了数据,那么y通常也是自动使用该Series的值。

383-2-3、**kwargs(可选)其他参数,传递给matplotlib的bar方法,例如:

  • color:设置条形的颜色;
  • alpha:设置透明度;
  • width:设置条形的宽度;
  • edgecolor:设置条形的边缘颜色;
  • title:图表的标题;
  • fontsize:轴标签和标题的字体大小等。
383-3、功能

        主要用于可视化一维数据,以清晰地显示不同值之间的比较,适合用于类别数据的统计分析,例如分组数据、特征比较等,可以通过x和y参数控制数据的来源,支持更复杂的可视化需求。

383-4、返回值

        返回一个matplotlib.axes.Axes对象,该对象可以用于进一步的定制和调整,返回的对象是matplotlib的轴对象,可以通过这个对象添加标题、设置标签和其他绘图属性。

383-5、说明

        使用场景:

383-5-1、类别数据比较:当需要比较不同类别的数量或其他数值时,条形图可以清晰地展示各类别之间的差异。例如,显示销售数据中各产品类别的销量。

383-5-2、频率分布:可以用于可视化数据的频率分布,比如展示每个分组(例如年龄段、收入水平等)的样本数量。这种情况下,条形图可以帮助快速识别数据的分布特征。

383-5-3、展示统计结果:在执行统计分析后,可以使用条形图展示统计结果,比如t测试或ANOVA分析的结果,帮助理解不同组之间的显著性差异。

383-5-4、变化趋势对比:在有多个时间点的数据时,可以通过条形图并排展示不同时间点、不同条件下的结果,从而比较趋势,这在营销分析、销售报告等场合很常见。

383-5-5、数据报告与演示:条形图因为直观易懂,适用于数据报告和演示,用条形图可以帮助观众更好地理解数据,尤其是在非数据专业背景的受众面前。

383-5-6、探索性数据分析:在数据分析的初始阶段,利用条形图快速识别数据中的模式、趋势和异常值,帮助分析师调整下一步的分析策略。

383-5-7、多个分类比较:可以通过堆叠条形图或并列条形图比较不同组之间的多个变量,比如比较不同地区、不同产品在同一时间段的销售表现。

383-6、用法
383-6-1、数据准备
383-6-2、代码示例
# 383、pandas.Series.plot.bar方法
# 383-1、类别数据比较
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 配置字体,确保中文字符正常显示
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['axes.unicode_minus'] = False  # 解决负号 '-' 显示问题
# 创建示例数据
data = {'产品类别': ['A', 'B', 'C', 'D'],
        '销量': [150, 200, 300, 250]}
df = pd.DataFrame(data)
# 绘制条形图
df.set_index('产品类别')['销量'].plot.bar(color='purple')
plt.title('各产品类别销量比较')
plt.xlabel('产品类别')
plt.xticks(rotation=0)
plt.ylabel('销量')
plt.show()

# 383-2、频率分布
import pandas as pd
import matplotlib.pyplot as plt
# 创建示例数据
data = {'年龄': [22, 24, 22, 23, 25, 24, 23, 30, 31, 30, 30]}
df = pd.DataFrame(data)
# 计算频率
age_counts = df['年龄'].value_counts()
# 绘制条形图
age_counts.plot.bar(color='green')
plt.title('年龄分布')
plt.xlabel('年龄')
plt.xticks(rotation=0)
plt.ylabel('人数')
plt.show()

# 383-3、展示统计结果
import pandas as pd
import matplotlib.pyplot as plt
# 创建示例数据
data = {'组别': ['组1', '组2', '组3'],
        '均值': [20, 35, 30]}
df = pd.DataFrame(data)
# 绘制条形图
df.set_index('组别')['均值'].plot.bar(color='coral')
plt.title('不同组别的均值比较')
plt.xlabel('组别')
plt.xticks(rotation=0)
plt.ylabel('均值')
plt.show()

# 383-4、变化趋势对比
import pandas as pd
import matplotlib.pyplot as plt
# 创建示例数据
data = {
    '年份': ['2020', '2021', '2022', '2023'],
    '产品A': [100, 150, 200, 250],
    '产品B': [80, 120, 180, 220]
}
df = pd.DataFrame(data).set_index('年份')
# 绘制并排条形图
df.plot.bar()
plt.title('产品A和产品B的年度销量比较')
plt.xlabel('年份')
plt.ylabel('销量')
plt.xticks(rotation=0)
plt.legend(title='产品')
plt.show()

# 383-5、数据报告与演示
import pandas as pd
import matplotlib.pyplot as plt
# 创建示例数据
data = {'项目': ['项目1', '项目2', '项目3'],
        '完成进度': [60, 80, 45]}
df = pd.DataFrame(data)
# 绘制条形图
df.set_index('项目')['完成进度'].plot.bar(color='purple')
plt.title('项目完成进度')
plt.xlabel('项目')
plt.xticks(rotation=0)
plt.ylabel('完成进度 (%)')
plt.ylim(0, 100)
plt.show()

# 383-6、探索性数据分析
import pandas as pd
import matplotlib.pyplot as plt
# 创建示例数据
data = {'城市': ['纽约', '洛杉矶', '芝加哥', '休斯顿'],
        '人口': [8419600, 3980400, 2716000, 2328000]}
df = pd.DataFrame(data)
# 绘制条形图
df.set_index('城市')['人口'].plot.bar(color='blue')
plt.title('美国主要城市人口比较')
plt.xlabel('城市')
plt.xticks(rotation=45)
plt.ylabel('人口')
plt.show()

# 383-7、多个分类比较
import pandas as pd
import matplotlib.pyplot as plt
# 创建示例数据
data = {
    '产品': ['产品A', '产品B', '产品C'],
    '2022年销售': [300, 450, 350],
    '2023年销售': [400, 500, 650]
}
df = pd.DataFrame(data)
# 设置产品为索引,绘制堆叠条形图
df.set_index('产品').plot.bar(stacked=True)
plt.title('产品销售比较(2022 vs 2023)')
plt.xlabel('产品')
plt.xticks(rotation=45)
plt.ylabel('销售')
plt.legend(title='年')
plt.show()
383-6-3、结果输出
# 383、pandas.Series.plot.bar方法
# 383-1、类别数据比较
# 见图14

# 383-2、频率分布
# 见图15

# 383-3、展示统计结果
# 见图16

# 383-4、变化趋势对比
# 见图17

# 383-5、数据报告与演示
# 见图18

# 383-6、探索性数据分析
# 见图19

# 383-7、多个分类比较
# 见图20

图14:

 

图15:

 

图16:

 

图17:

 

图18:

 

图19:

 

图20:

 

384、pandas.Series.plot.barh方法
384-1、语法
# 384、pandas.Series.plot.barh方法
pandas.Series.plot.barh(x=None, y=None, **kwargs)
Make a horizontal bar plot.

A horizontal bar plot is a plot that presents quantitative data with rectangular bars with lengths proportional to the values that they represent. A bar plot shows comparisons among discrete categories. One axis of the plot shows the specific categories being compared, and the other axis represents a measured value.

Parameters:
x
label or position, optional
Allows plotting of one column versus another. If not specified, the index of the DataFrame is used.

y
label or position, optional
Allows plotting of one column versus another. If not specified, all numerical columns are used.

color
str, array-like, or dict, optional
The color for each of the DataFrame’s columns. Possible values are:

A single color string referred to by name, RGB or RGBA code,
for instance ‘red’ or ‘#a98d19’.

A sequence of color strings referred to by name, RGB or RGBA
code, which will be used for each column recursively. For instance [‘green’,’yellow’] each column’s bar will be filled in green or yellow, alternatively. If there is only a single column to be plotted, then only the first color from the color list will be used.

A dict of the form {column namecolor}, so that each column will be
colored accordingly. For example, if your columns are called a and b, then passing {‘a’: ‘green’, ‘b’: ‘red’} will color bars for column a in green and bars for column b in red.

**kwargs
Additional keyword arguments are documented in DataFrame.plot().

Returns:
matplotlib.axes.Axes or np.ndarray of them
An ndarray is returned with one matplotlib.axes.Axes per column when subplots=True.
384-2、参数

384-2-1、x(可选,默认值为None)字符串或None,在Series对象中,默认使用其索引作为y轴。如果提供x参数,它将采用x字段作为x轴的值,这在DataFrame的上下文中更常用,对于Series,通常不用设置。

384-2-2、y(可选,默认值为None)字符串或None,与x参数类似,通常不适用于Series,而是用于DataFrame进行指定y轴的数值,对于Series,数据本身作为y轴的值。

384-2-3、**kwargs(可选)其他参数,传递给matplotlib的bar方法,例如:

  • color:设置条形的颜色;
  • alpha:设置透明度;
  • width:设置条形的宽度;
  • edgecolor:设置条形的边缘颜色;
  • title:图表的标题;
  • fontsize:轴标签和标题的字体大小等。
384-3、功能

        将Series数据以水平条形图的形式进行可视化,这使得数据的比较更加直观,尤其方便于展示不同类别的大小差异,适合用于查看长分类名称的情况等。

384-4、返回值

        返回绘制该图的Axed对象,这样用户可以在图形上进一步进行修改和自定义,可以使用该对象的方法进行额外的图形调整,如添加标题、标签等。

384-5、说明

        使用场景:

384-5-1、类别比较:当需要比较不同类别之间的数值时,水平条形图可以使长类别名称得到更好的展示。例如,展示不同产品销售额、不同国家的人口、用户满意度评分等。

384-5-2、处理长类别标签:在类别的标签较长或数量较多时,水平条形图能有效避免标签重叠的问题,使得数据更加清晰易读。

384-5-3、展示分布:用于展示数据的分布情况。比如,展示各个年龄段的人数分布、各个地区的销售数据等,能够直观反映每个类别的相对大小。

384-5-4、数据排名:当需要展示数据的排名,比如最佳销售人员、最受欢迎的电影等,水平条形图能够有效地显示不同条目之间的相对排名。

384-5-5、分组比较:在分析分组数据时,可以使用水平条形图展示不同组别之间的比较情况。例如,比较不同部门的业绩或项目的进展。

384-5-6、结果展示:在报告或演讲中,使用水平条形图可以帮助观众快速抓住数据的重点,增强信息的传达效果。

384-6、用法
384-6-1、数据准备
384-6-2、代码示例
# 384、pandas.Series.plot.barh方法
# 384-1、类别比较
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 配置字体,确保中文字符正常显示
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['axes.unicode_minus'] = False  # 解决负号 '-' 显示问题
# 创建示例数据
data = {'产品': ['产品A', '产品B', '产品C', '产品D'],
        '销售额': [150, 250, 100, 200]}
df = pd.DataFrame(data)
# 绘制水平条形图
df.plot.barh(x='产品', y='销售额', color='blue', legend=False)
plt.title('不同产品销售额比较')
plt.xlabel('销售额 (万元)')
plt.ylabel('产品')
plt.show()

# 384-2、处理长类别标签
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 配置字体,确保中文字符正常显示
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['axes.unicode_minus'] = False  # 解决负号 '-' 显示问题
# 创建示例数据
data = {'国家': ['中华人民共和国', '美利坚合众国', '印度', '巴西', '俄罗斯联邦'],
        '人口': [1400000000, 330000000, 1400000000, 210000000, 160000000]}
df = pd.DataFrame(data)
# 绘制水平条形图
df.plot.barh(x='国家', y='人口', color='green', legend=False)
plt.title('各国人口比较')
plt.xlabel('人口 (亿)')
plt.ylabel('国家')
plt.show()

# 384-3、展示分布
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 配置字体,确保中文字符正常显示
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['axes.unicode_minus'] = False  # 解决负号 '-' 显示问题
# 创建示例数据
age_groups = ['0-18', '19-35', '36-50', '51-65', '65+']
population = [1000, 2500, 3000, 1500, 800]
df = pd.Series(population, index=age_groups)
# 绘制水平条形图
df.plot.barh(color='purple', legend=False)
plt.title('不同年龄段人口分布')
plt.xlabel('人口数量')
plt.ylabel('年龄段')
plt.show()

# 384-4、数据排名
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 配置字体,确保中文字符正常显示
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['axes.unicode_minus'] = False  # 解决负号 '-' 显示问题
# 创建示例数据
data = {'员工': ['小张', '小李', '小王', '小赵', '小孙'],
        '销售业绩': [400, 700, 500, 300, 600]}
df = pd.DataFrame(data)
# 按销售业绩排名
df = df.sort_values(by='销售业绩', ascending=False)
# 绘制水平条形图
df.plot.barh(x='员工', y='销售业绩', color='skyblue', legend=False)
plt.title('员工销售业绩排名')
plt.xlabel('销售业绩 (万元)')
plt.ylabel('员工')
plt.show()

# 384-5、分组比较
import pandas as pd
import matplotlib.pyplot as plt
# 创建示例数据
data = {
    '部门': ['市场部', '研发部', '销售部', '客服部'],
    '2022年业绩': [150, 200, 250, 100],
    '2023年业绩': [180, 220, 270, 120]
}
df = pd.DataFrame(data)
# 设置数据为多层索引
df.set_index('部门', inplace=True)
df.plot.barh(stacked=False)
plt.title('各部门年度业绩比较')
plt.xlabel('业绩 (万元)')
plt.ylabel('部门')
plt.legend(title='年度')
plt.show()
384-6-3、结果输出
# 384、pandas.Series.plot.barh方法
# 384-1、类别比较
# 见图21

# 384-2、处理长类别标签
# 见图22

# 384-3、展示分布
# 见图23

# 384-4、数据排名
# 见图24

# 384-5、分组比较
# 见图25

图21:

 

图22:

 

图23:

 

图24:

 

图25:

 

385、pandas.Series.plot.box方法
385-1、语法
# 385、pandas.Series.plot.box方法
pandas.Series.plot.box(by=None, **kwargs)
Make a box plot of the DataFrame columns.

A box plot is a method for graphically depicting groups of numerical data through their quartiles. The box extends from the Q1 to Q3 quartile values of the data, with a line at the median (Q2). The whiskers extend from the edges of box to show the range of the data. The position of the whiskers is set by default to 1.5*IQR (IQR = Q3 - Q1) from the edges of the box. Outlier points are those past the end of the whiskers.

For further details see Wikipedia’s entry for boxplot.

A consideration when using this chart is that the box and the whiskers can overlap, which is very common when plotting small sets of data.

Parameters:
bystr or sequence
Column in the DataFrame to group by.

Changed in version 1.4.0: Previously, by is silently ignore and makes no groupings

**kwargs
Additional keywords are documented in DataFrame.plot().

Returns:
matplotlib.axes.Axes
or numpy.ndarray of them.
385-2、参数

385-2-1、by(可选,默认值为None)指定分组变量,可以用来将数据按某个分类变量分组绘制多个箱线图,如果没有此参数,绘制的箱线图将显示整个系列的分布。

385-2-3、**kwargs(可选)其他参数,传递给matplotlib的bar方法,例如:

  • color:设置条形的颜色;
  • alpha:设置透明度;
  • width:设置条形的宽度;
  • edgecolor:设置条形的边缘颜色;
  • title:图表的标题;
  • fontsize:轴标签和标题的字体大小等。
385-3、功能

        用于绘制箱线图(Box Plot),以可视化一维数据的分布,箱线图能够显示数据的中位数、四分位数、异常值等信息,非常适合用于了解数据的分布情况和特征。

385-4、返回值

        返回一个Matplotlib Axes对象,允许进一步的自定义和调整。

385-5、说明

        使用场景:

385-5-1、数据分布分析:在数据探索阶段,箱线图可用于快速了解数据的分布情况、集中趋势和离散程度,帮助识别数据的偏态和异常值。例如,分析销售数据的分布时,可以识别出某些区域的异常销售情况。

385-5-2、比较不同分类的数值:箱线图可以清晰地展示不同组别之间的差异。例如,分析不同产品类别的价格分布,可以通过绘制分组箱线图来比较各类别的价格中位数及异常值,从而判断最佳定价策略。

385-5-3、财务数据分析:在财务领域,箱线图可以用于展示不同时间段(如季度、年度)的收入、费用及利润的分布,识别潜在的财务风险和异常情况。例如,识别某个月的异常支出。

385-5-4、实验数据分析:在科研实验中,特别是在生物统计学中,可以使用箱线图来比较不同处理组的实验结果,判断各组之间的差异是否显著,从而支持实验结论。

385-5-5、教育数据分析:教育机构可以利用箱线图分析学生成绩的分布,识别高分和低分学生,有针对性地展开辅导,同时可以比较不同年级或班级之间的学习成绩差异。

385-5-6、用户行为分析:在产品、网站或应用的用户行为分析中,箱线图可以用于展示用户访问时长、页面停留时间等指标的分布,帮助识别出活跃和沉默用户,优化用户体验。

385-5-7、质量控制:制造业或服务行业可以利用箱线图分析产品质量数据,如生产缺陷率、时间测量等,监控生产过程是否稳定,并快速识别问题领域。

385-6、用法
385-6-1、数据准备
385-6-2、代码示例
# 385、pandas.Series.plot.box方法
# 385-1、数据分布分析
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 配置字体,确保中文字符正常显示
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['axes.unicode_minus'] = False  # 解决负号 '-' 显示问题
# 创建示例数据
data = {'成绩': [88, 92, 79, 95, 90, 67, 85, 100, 84, 76, 55, 97]}
df = pd.DataFrame(data)
# 绘制箱线图
plt.figure(figsize=(8, 6))
df['成绩'].plot.box()
plt.title('学生成绩分布箱线图')
plt.ylabel('成绩')
plt.show()

# 385-2、比较不同分类的数值
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 配置字体,确保中文字符正常显示
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['axes.unicode_minus'] = False  # 解决负号 '-' 显示问题
# 创建示例数据
data = {
    '产品类别': ['电子', '电子', '服装', '服装', '家具', '家具', '电子', '服装', '家具', '电子'],
    '价格': [200, 150, 50, 80, 300, 280, 220, 60, 100, 190]
}
df = pd.DataFrame(data)
# 绘制按“产品类别”分类的箱线图
plt.figure(figsize=(8, 6))
df.boxplot(column='价格', by='产品类别')
plt.title('不同产品类别价格分布箱线图')
plt.suptitle('')
plt.ylabel('价格')
plt.show()

# 385-3、财务数据分析
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 配置字体,确保中文字符正常显示
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['axes.unicode_minus'] = False  # 解决负号 '-' 显示问题
# 创建示例数据(每月收入)
data = {
    '月份': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct'],
    '收入': [1500, 2000, 2500, 2400, 3000, 2200, 3200, 3150, -500, 4000]  # 九月有异常值
}
df = pd.DataFrame(data)
# 绘制收入箱线图
plt.figure(figsize=(8, 6))
df['收入'].plot.box()
plt.title('每月收入分布箱线图')
plt.ylabel('收入')
plt.show()

# 385-4、用户行为分析
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 配置字体,确保中文字符正常显示
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['axes.unicode_minus'] = False  # 解决负号 '-' 显示问题
# 创建示例数据(用户访问时长)
data = {
    '用户类型': ['活跃', '活跃', '沉默', '活跃', '沉默', '沉默', '沉默', '活跃', '活跃', '沉默'],
    '访问时长(分钟)': [30, 45, 1, 50, 2, 10, 5, 40, 55, 3]
}
df = pd.DataFrame(data)
# 绘制按“用户类型”分类的访问时长箱线图
plt.figure(figsize=(8, 6))
df.boxplot(column='访问时长(分钟)', by='用户类型')
plt.title('不同用户类型访问时长分布箱线图')
plt.suptitle('')
plt.ylabel('访问时长(分钟)')
plt.show()

# 385-5、教育数据分析
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 配置字体,确保中文字符正常显示
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['axes.unicode_minus'] = False  # 解决负号 '-' 显示问题
# 创建示例数据(班级成绩)
data = {
    '班级': ['一班', '一班', '二班', '二班', '二班', '一班', '一班', '二班', '三班', '三班'],
    '考试成绩': [85, 90, 76, 88, 92, 69, 95, 80, 70, 100]
}
df = pd.DataFrame(data)
# 绘制按“班级”分类的考试成绩箱线图
plt.figure(figsize=(8, 6))
df.boxplot(column='考试成绩', by='班级')
plt.title('不同班级考试成绩分布箱线图')
plt.suptitle('')
plt.ylabel('考试成绩')
plt.show()

# 385-6、健康数据分析
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 配置字体,确保中文字符正常显示
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['axes.unicode_minus'] = False  # 解决负号 '-' 显示问题
# 创建示例数据(体重数据)
data = {
    '性别': ['男', '男', '女', '女', '女', '男', '女', '男', '女', '男'],
    '体重(kg)': [70, 80, 55, 60, 50, 75, 58, 85, 52, 90]
}
df = pd.DataFrame(data)
# 绘制按“性别”分类的体重箱线图
plt.figure(figsize=(8, 6))
df.boxplot(column='体重(kg)', by='性别')
plt.title('不同性别体重分布箱线图')
plt.suptitle('')
plt.ylabel('体重(kg)')
plt.show()

# 385-7、产品评分分析
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 配置字体,确保中文字符正常显示
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['axes.unicode_minus'] = False  # 解决负号 '-' 显示问题
# 创建示例数据(产品评分)
data = {
    '产品': ['A', 'B', 'A', 'B', 'A', 'B', 'C', 'C', 'C', 'C'],
    '评分': [4, 5, 3, 4, 5, 2, 4, 4, 3, 5]
}
df = pd.DataFrame(data)
# 绘制按“产品”分类的评分箱线图
plt.figure(figsize=(8, 6))
df.boxplot(column='评分', by='产品')
plt.title('不同产品评分分布箱线图')
plt.suptitle('')
plt.ylabel('评分')
plt.ylim(0, 6)  # 设置y轴范围
plt.show()

# 385-8、销售数据分析
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 配置字体,确保中文字符正常显示
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['axes.unicode_minus'] = False  # 解决负号 '-' 显示问题
# 创建示例数据(季度销售额)
data = {
    '季度': ['Q1', 'Q2', 'Q3', 'Q4', 'Q1', 'Q2', 'Q3', 'Q4'],
    '销售额(万)': [200, 220, 250, 300, 280, 300, 320, 350]
}
df = pd.DataFrame(data)
# 绘制按“季度”分类的销售额箱线图
plt.figure(figsize=(8, 6))
df.boxplot(column='销售额(万)', by='季度')
plt.title('不同季度销售额分布箱线图')
plt.suptitle('')
plt.ylabel('销售额(万)')
plt.show()

# 385-9、在线课程完成情况分析
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 配置字体,确保中文字符正常显示
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['axes.unicode_minus'] = False  # 解决负号 '-' 显示问题
# 创建示例数据(课程完成情况)
data = {
    '课程': ['课程A', '课程B', '课程C', '课程A', '课程B', '课程C', '课程A', '课程B'],
    '完成率(%)': [85, 90, 75, 80, 60, 95, 70, 100]
}
df = pd.DataFrame(data)
# 绘制按“课程”分类的完成率箱线图
plt.figure(figsize=(8, 6))
df.boxplot(column='完成率(%)', by='课程')
plt.title('不同课程完成率分布箱线图')
plt.suptitle('')
plt.ylabel('完成率(%)')
plt.ylim(0, 110)  # 设置y轴范围
plt.show()

# 385-10、网站流量分析
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 配置字体,确保中文字符正常显示
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['axes.unicode_minus'] = False  # 解决负号 '-' 显示问题
# 创建示例数据(每日流量)
data = {
    '日期': pd.date_range(start='2023-01-01', periods=30),
    '流量(人次)': [120, 150, 130, 200, 180, 160, 175, 190, 210, 220,
                   150, 130, 170, 160, 165, 180, 185, 190, 200, 210,
                   150, 140, 180, 175, 160, 155, 165, 190, 200, 210]
}
df = pd.DataFrame(data)
# 绘制流量的箱线图
plt.figure(figsize=(10, 6))
df['流量(人次)'].plot.box()
plt.title('每日网站流量分布箱线图')
plt.ylabel('流量(人次)')
plt.show()
385-6-3、结果输出
# 385、pandas.Series.plot.box方法
# 385-1、数据分布分析
# 见图26

# 385-2、比较不同分类的数值
# 见图27

# 385-3、财务数据分析
# 见图28

# 385-4、用户行为分析
# 见图29

# 385-5、教育数据分析
# 见图30

# 385-6、健康数据分析
# 见图31

# 385-7、产品评分分析
# 见图32

# 385-8、销售数据分析
# 见图33

# 385-9、在线课程完成情况分析
# 见图34

# 385-10、网站流量分析
# 见图35

图26:

 

 图27:

图28:

图29:

图30:

图31:

图32:

图33:

图34:

图35:

 

二、推荐阅读

1、Python筑基之旅
2、Python函数之旅
3、Python算法之旅
4、Python魔法之旅
5、博客个人主页

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2056764.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

嵌入式软件开发学习二:GPIO

Tips: 本文全部的TTL肖特基触发器应该均为施密特触发器,有些忘记改了。 资料来源:[3-1] GPIO输出_哔哩哔哩_bilibili 一、GPIO简介: GPIO(General Purpose Input Output)是指通用输入输出接口,…

GitLab Merge Request流水线

GitLab Merge Request 流程文档 为了提升代码质量,让开发人员参与代码review,现在输出Merge Request的流程文档: 1.项目创建各自开发者的分支,命名规则是dev_名字首字母,比如我是dev_cwq.然后把本地分支推到远端orgin…

数据库管理-第232期 初探OpenTenBase(20240819)

数据库管理232期 2024-08-19 数据库管理-第232期 初探OpenTenBase(20240819)1 OpenTenBase简介2 架构介绍3 集群规划4 部署集群4.1 操作系统配置4.2 数据库软件下载与安装4.3 配置集群4.4 分发软件4.5 启动数据库4.6 查看集群状态 5 访问数据库总结 数据…

Java并发常见面试题总结

文章目录 1 多线程1.1 进程、线程和协程的区别?🔥1.2 Java 线程和操作系统的线程有啥区别?1.3 如何创建线程?🔥1.4 runnable 和 callable 两个接口创建线程有什么不同呢?🔥1.5 如何停止一个正在…

2024.8.20

思维导图 C语言中指针数组和数组指针的区别 数组指针本质上是一个指针变量,用于存储整个数组的起始地址,指针每偏移一个单位,内存就会偏移整个数组的容量的大小,一般用于二维数组,二维数组的数组名,本质上是…

【可视化】封装滚动菜单列表组件

源码及源码分析 <template><!-- 滚动菜单的主要容器 --><div class"scrolling-menu"><!-- 如果headers数组有内容&#xff0c;就渲染表头 --><divclass"table-header"v-if"headers.length":style"{ backgroundC…

LLM向量嵌入知多少

向量嵌入是机器学习领域中一项引人入胜且极具实用性的技术。它们构成了众多自然语言处理&#xff08;NLP&#xff09;、推荐系统和搜索算法的基础。如果您曾经使用过推荐引擎、语音助手或语言翻译工具&#xff0c;那么您已经体验过嵌入技术的强大功能。 机器学习算法&#xff0…

如何为您的专用IP地址选择正确的IP SSL证书

随着互联网的不断发展&#xff0c;网站安全变得越来越重要。SSL证书不仅为网站提供了加密通道&#xff0c;还增强了用户对网站的信任感。对于那些使用专用IP地址的网站来说&#xff0c;选择合适的IP SSL证书至关重要。本文将为您详细介绍如何挑选最适合您网站需求的IP SSL证书。…

Cocos Creator2D游戏开发(14)---CocosCreator常用组件详解

Canvas RenderRoot2D 组件所在的节点是 2D 渲染组件数据收集的入口,而 Canvas&#xff08;画布&#xff09; 组件继承自 RenderRoot2D 组件&#xff0c;所以 Canvas 组件也是数据收集入口。所有 2D 渲染元素都必须作为 RenderRoot2D 的子节点才能被渲染。 Canvas还作为屏幕适配…

Web基础、http协议、源码编译构建LAMP

目录 一、DNS与域名 1.1域名概述 1.2域名小结 1.3DNS域名解析 1.4域名 二、网页的概念 1.网页的基本概念 三、web 1.1web概述 1.2渲染过程 1.3web1.0和web2.0 1.4静态页面和动态页面 四、http协议 1.http协议简介 2.cookie和session 2.1cookie 2.2session 3.c…

React学习笔记(一)——react基础

1. React 介绍 1.1 React是什么 React由Meta公司研发&#xff0c;是一个用于 构建Web和原生交互界面的库 1.2 React的优势 相较于传统基于DOM开发的优势&#xff1a; 组件化的开发方式不错的性能 相较于其它前端框架的优势&#xff1a; 丰富的生态跨平台支持 1.3 React的市场…

国内知名电器集团售后服务系统被黑!损失1.2亿!

两款软件入侵 近期&#xff0c;一款名为“A助手”的软件和另一款“B配置工具”被揭露存在严重的非法活动。 这两款软件被不法分子利用&#xff0c;并成功侵入了某知名企业的电器售后服务系统。通过技术手段&#xff0c;伪造了电器安装服务的工单&#xff0c;并以此骗取了大量的…

24年银行从业资格考试报名照规格要求

24年银行从业资格考试报名照规格要求 #银行从业 #银行从业资格证 #银行从业考试 #银行从业资格考试 #银行从业资格证报名照片 #银从

Unity 波函数坍缩算法随机地图生成

Unity 波函数坍缩算法随机地图生成 波函数波函数基本概念位置空间波函数动量空间波函数两种波函数之间的关系波函数的本征值和本征态波函数坍缩 熵是什么熵作为状态函数时间之箭 实现原理举个例子&#xff1a;2D迷宫地图生成 Unity 如何实现前期准备单元格代码瓦片地图代码波函…

使用亮数据爬虫工具解锁复杂爬虫场景

在当今数据驱动型时代&#xff0c;数据采集和分析能力算是个人和企业的核心竞争力。然而&#xff0c;手动采集数据耗时费力且效率低下&#xff0c;而且容易被网站封禁。 我之前使用过一个爬虫工具&#xff0c;亮数据&#xff08;Bright Data&#xff09; &#xff0c;是一款低…

PCIe学习笔记(25)

数据完整性 PCI Express的基本数据可靠性机制包含在数据链路层(data Link Layer)中&#xff0c;它使用32位的LCRC (CRC)码逐链路检测TLP中的错误&#xff0c;并采用逐链路重传机制进行错误恢复。TLP是一个数据和事务控制单元&#xff0c;由位于PCI Express域“边缘”的数据源(…

重大发现!看Apache与nginx工作模型,享web服务幸福人生

文章目录 文章相关连接如下&#xff1a; Web 服务基础介绍ApacheApache prefork 模型 Apache worker 模型Apache event模型 Nginx-高性能的 Web 服务端nginx源码安装平滑升级和回滚平滑升级步骤&#xff1a;回滚步骤 nginx启动文件 文章相关连接如下&#xff1a; 如果想更多了…

【GH】【EXCEL】P4: Chart

文章目录 data and chartdonut chart (radial chart)Radial Chart bar chartBar Chart line chartLine Chart Scatter ChartScatter Chart Surface ChartSurface Chart Chart DecoratorsChart Decorators Chart GraphicsChart Graphics data and chart donut chart (radial cha…

《面板变系数模型及 Stata 具体操作步骤》

目录 一、文献综述 二、理论原理 三、实证模型 四、稳健性检验 五、程序代码及解释 六、代码运行结果 一、文献综述 在经济和社会科学研究领域&#xff0c;面板数据模型因其能够同时考虑个体和时间维度的信息而被广泛应用。传统的面板数据模型通常假设系数是固定的&#…

1.初识redis

文章目录 1.认识redis1.1 mysql和redis 对比1.2分布式系统1.2.1单机架构与分布式架构1.2.2数据库分离(应用服务器和存储服务器分离)与负载均衡1.2.3负载均衡器1.2.4 数据库读写分离1.2.5 数据库服务器引入缓存1.2.6数据库分库分表1.2.7 引入微服务 2.常见概念解释2.1 应用(Appl…