In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "what is the use of the Python Pandas library", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "what is the use of the Python Pandas library" bar!
Beginners and rookies who have just come into contact with Python can copy the following link to watch the basic introductory teaching video of Python for free.
Https://v.douyu.com/author/y6AZ4jn9jwKW
First, an overview of visualization
There are three common data visualization libraries in Python:
Matplotlib: the most commonly used library, which can be regarded as a necessary skill library for visualization, is more complex, has a lot of api, and is not easy to learn.
Seaborn: refactoring on the basis of matplotlib, can meet the visualization needs, more special needs still need to learn matplotlib.
Pyecharts: the above two libraries are static visualization libraries, while pyecharts has good network compatibility and can achieve visual dynamic effects. And the variety is also rich. This kind of picture is very powerful: the drawing artifact pyecharts- the rising sun
Pandas: today we are going to talk about the visualization of Pandas. Pandas is mainly used as a library for data analysis. Although it is not as powerful as the above three libraries, it is more convenient. In the process of data analysis, only one line of code can be realized. And very beautiful.
Second, look at the case directly.
Among the pandas, there are 11 common graphic visualization and several more advanced ones. Let's see how to draw them one by one.
Import pandas as pdimport numpy as npdf= pd.DataFrame (np.random.rand (10, 4), columns= ['Achievement df.plot.bar ()]) 01, histogram-preliminary df.plot.bar ()
Stack = True, draw stacked bar chart
Df.plot.bar (stacked=True)
Again, stacked = True, draw a stacked bar chart
Df.plot.barh (stacked=True)
Df.plot.area (stacked=True,alpha = 0.9)
05, density map-densitydf.plot.density ()
06, histogram
Change to another dataset
Df = pd.DataFrame ({'Aids: np.random.randn (1000) + 1,' bones: np.random.randn (1000), 'cations: np.random.randn (1000)-1}, columns= [' Aids, 'bones,' C']) df.plot.hist (bins=200)
Df.plot.hist (stacked=True, bins=20)
Df= pd.DataFrame (np.random.rand (1000, 4), columns= ['Achilles df.diff (). Hist (color='k', alpha=0.7, bins=50)
07, the box diagram df= pd.DataFrame (np.random.rand (100,4), columns= ['A', A', B, M, C, D']) df.plot.box ()
08, scatter plot df.plot.scatter (Xerox scatter chart, scatter plot, scatter chart, scatter chart, scatter graph, scatter chart, scatter chart, scatter graph, scatter graph, scatter chart, scatter graph, scatter chart, scatter chart, scatter graph, scatter
09, Honeycomb df = pd.DataFrame (np.random.randn (1000, 2), columns= ['axiom,' b']) df ['b'] = df ['b'] + np.arange (1000) df.plot.hexbin (xylene, yawning, gridsize=25)
07, pie chart series = pd.Series (3 * np.random.rand (4), index= ['await,' baked, 'cased,' d'], name='series') series.plot.pie (figsize= (6,6))
08, matrix scatter graph from pandas.plotting import scatter_matrixdf = pd.DataFrame (np.random.randn (1000, 4), columns= ['await,' baked, 'cased,' d']) scatter_matrix (df, alpha=0.2, figsize= (6,6), diagonal='kde')
09, Andrews curve data = pd.read_csv ('CJV _ peg _ UsersPlacement Wuzhengxiang _ _ Desktopmax _ iris. CSV') pd.plotting.andrews_curves (data, 'Name')
Andrews_curves (data, 'Name', colormap='winter')
10, parallel coordinate diagram which also uses the self-loaded iris data set from pandas.plotting import parallel_coordinatesparallel_coordinates (data, 'Name', colormap='gist_rainbow')
11, lag graph from pandas.plotting import lag_plotdf= pd.Series (0.1 * np.random.rand (1000) + 0.9 * np.sin (np.linspace (- 99 * np.pi, 99 * np.pi, num=1000)) lag_plot (df)
12, maximum function graph
Draw directly, preset as a line chart
Df= pd.DataFrame (np.random.rand (12,4), columns= ['Achilles pyrrhenium']) df.plot ()
Df.plot (subplots=True,layout= (2,2), figsize= (15,8))
Df= pd.DataFrame (np.random.rand (1000, 4), columns= ['Achilles pyrrhenium']) df.plot ()
Df.plot (subplots=True,layout= (2,2), figsize= (15,8))
13 pd.Series bootstrappers plots = (np.random.uniform (size=100)) pd.plotting.bootstrap_plot (s)
3. Parameter details 1, official document https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.plot.htmlhttps://pandas.pydata.org/pandas-docs/version/0.18.1/visualization.html2 Parameter description DataFrame.plot (x=None, y=None, kind='line', ax=None, subplots=False, sharex=None, sharey=False, layout=None, figsize=None, use_index=True, title=None, grid=None, legend=True, style=None, logx=False, logy=False, loglog=False, xticks=None, yticks=None, xlim=None, ylim=None, rot=None, fontsize=None, colormap=None, position=0.5, table=False, yerr=None,xerr=None, stacked=True/False, sort_columns=False, secondary_y=False, mark_right=True, * * kwds)
Note: each drawing type has a corresponding method: df.plot (kind = 'line') is equivalent to df.plot.line ()
X: label or location, which defaults to the label or location parameter of the None# index column
Y: tag, location or tag list, location. Default value is none.
Category: str# drawing type
'line': line chart (default) # line chart
'The bar': vertical bar chart. Bar chart. Stacked bar chart when stacked is True
'barh': horizontal bar chart
'hist':histogram# histogram (numerical frequency distribution)
'box':boxplot# box diagram
Kde': kernel density estimation chart # density chart, mainly adding kernel probability density lines to the bar chart
Density: same as' kde''
The area map (area map) around the area':area plot# and the x-axis. When Stacked= True, each column must be all positive or negative. When stacked = False, there is no requirement for data.
Pie':pie plot# pie chart. The value must be positive, you need to specify the Y axis or subplots = True
Scatter': scatter plot # scatter plot X axis and Y axis need to be specified
'hexbin':hexbin figure # Honeycomb chart. X axis and Y axis need to be specified
'hexbin':hexbin figure # Honeycomb chart. X axis and Y axis need to be specified
Ax:matplotlib axis object, which defaults to the None#** subgraph (axes, which can also be understood as an axis) the matplotlib subgraph object on which to trade. If it is not set, the current matplotlib subgraph * * is used, where variables and functions describe figure and axes together by changing the elements in figure and axes (for example, title,label, points and lines, etc.), that is, drawing on the canvas.
Subgraph: Boolean value. The default is whether False# makes a subgraph of the column.
Sharex: Boolean. Default is true. If ax is None False#, if ax is None, set to True, otherwise False.
If subplots = True, the x-axis is shared and some x-axis labels are made invisible; if ax is None, the default is True, otherwise it is False. Note that passing ax and sharex = True at the same time changes all x-axis labels for all axes in the drawing!
Sharey: Boolean value. Default is False#. If there is a subgraph, the subgraph shares the y-axis scale, label.
If subplots = True, share the y-axis and set some y-axis labels to invisible
Layout: tuple (row, column) for subgraph # column layout of subgraph
Figsize: tuples in inches (width, height)
Use_index: Boolean value, default is True
Title: string # the title of the picture is a string
Parcel title
Grid: Boolean value. The default value is whether None# pictures have grids.
Legend of legend:False / True / 'reverse'# subgraph (alternating with True)
Style: list or dictionary # sets the type of line for each column of line chart
Logx: Boolean value. Default is False.
Type: Boolean, default is False
Loglog: Boolean value, which defaults to False# and sets the logarithm of the XBI y-axis scale.
Xticks:sequence# sets the x-axis scale value, in sequence form (some lists)
Yticks:sequence# sets y-axis scale, sequence form (several lists)
Xlim:float / 2-tuple / list# sets the range of axes. Numeric value (variable), list or tuple (interval range)
Ylim: floating point / 2 tuples / list
Rot:int, the default value None# sets the display rotation degrees of the axis label (axis scale)
Fontsize:int, the default value None# sets the font size of the axis scale
Colormap:str or matplotlib colormap object, the default value is None.
Colorbar: Boolean value, optional # column color
If True, draw a color bar (only related to scatter and hexagonal graphs)
Alignment of position:float# bar chart. The value range is [0J1], that is, 0.5 is replaced from the lower left end to the upper right end (middle alignment)
Layout:tuple (optional) # layout. Layout= (2mae3) two rows and three columns, layout= (2maimei 1) two rows adaptive columns
For example. Df.plot (subplots = True,layout = (2mailim 1), sharex = False)
Table: Boolean value, Series or DataFrame. The default is to add tables under the False# diagram. If True, the data chart in DataFrame is used, and the data is rotated and placed into the layout of matplotlib.
Yer:DataFrame,Series, class array, dict and str
For more information, see drawing with error lines.
Xerr: the same type as yerr.
Stacking: Boolean, linear and bar charts default to False, area chart is True. If True, create a stacking diagram. # there is an introduction earlier
Sort_columns: Boolean value. The default value is False.
Secondary_y: Boolean value or sequence, defaults to False# setting the second y-axis (right auxiliary y-axis)
Whether to draw on the secondary y-axis, if it is a list / tuple, which columns are drawn on the secondary y-axis
Mark_right: Boolean value, default is True
Thank you for your reading, the above is "what is the use of Python Pandas library" content, after the study of this article, I believe you have a deeper understanding of the use of Python Pandas library is what this problem, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.