In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to achieve Pandas data visualization of the basic drawing, I hope you will learn something after reading this article, let's discuss it together!
1. Environment
IDE: jupyter notebook
Anaconda 3.X
2. Based on matplotlib
Import matplotlib.pyplot as plt
Note: import matplotlib.pyplot
Import matplotlib
Matplotlib.style.use ('ggplot')
% matplotlib inline
Note: use ggplot style and draw in jupyter notebook
Import pandas as pd
Import numpy as np
Ts = pd.Series (np.random.randn (1000), index=pd.date_range ('1max), periods=1000))
Ts.plot ()
Note: use pandas to create a Series (sequence) with randomly generated 1000 standard normal distribution values and an index of 1000 time series values starting from 2000-1-1.
Then draw by default using plot. As you can see, the following figure is very irregular because the two adjacent values are also random in size.
Import pandas as pd
Import numpy as np
Ts = pd.Series (np.random.randn (1000), index=pd.date_range ('1max), periods=1000))
Ts = ts.cumsum ()
Ts.plot ()
Note: ts = ts.cumsum () is added here, which means to return the cumulative value. In time series analysis, the cumulative value curve is often observed to observe the trend.
This cumulative value seems to be more regular.
Df = pd.DataFrame (np.random.randn (1000, 4), index=ts.index, columns=list ('ABCD'))
Df = df.cumsum ()
Plt.figure ()
Df.plot ()
Note: here you use pandas to create a DataFrame (data box, a bit like an excel table), so why not use the Series just now? Because four sets of data are created in DataFrame, these four sets of data are randomly generated 1000 standard normal distribution values, the index is 1000 time series values starting from 2000-1-1, and also calculate their cumulative values and draw pictures.
Df3 = pd.DataFrame (np.random.randn (1000, 2), columns= ['baked,' C']) .cumsum ()
Df3 ['A'] = pd.Series (list (range (len (df)
Df3.plot (x, y, y, etc.)
Note: two sets of data, also 1000 standard normal distributions, are created using DataFrame, named B and C respectively (column names in line excel). And find the cumulative value, and then in the original df (abbreviation of DataFrame) (here the name is df3), add a list of values named A Magi An is 0-999 (using the length of df3 is 1000, and then range is trapped list to generate a column number, as the x axis), the y axis is B column data (cumulative value), c column data is not used in the final drawing.
Finally, the Pandas basic drawing plot is completed!
After reading this article, I believe you have a certain understanding of "how to realize the basic drawing of data visualization in Pandas". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
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.