当前位置:网站首页>[original dry goods] found a useful tool for data analysis
[original dry goods] found a useful tool for data analysis
2022-07-23 07:54:00 【Xinyi 2002】
Xiaobian recently encountered a sharp tool for data analysis , We can display the data we need on the web , And carry out relatively deep data analysis and mining , So I plan to take this opportunity to share with you .
About streamlit-aggrid
We know how to use Streamlit Module to do web Application development is really very convenient , However, it is very simple in displaying tables , There are only two simple interface functions , Namely st.table(df) and st.dataframe(df), The display of table data with many fields is very unfriendly , Today, Xiaobian will introduce one Streamlit Plug in for ,streamlit-aggrid, Its basic functions include
Data sorting
Adjustment of table style
Data filtering
Page turning
wait
First we go through pip Command to download the module
pip install streamlit-aggridLet's write a simple demo, Let's see what functions this module can achieve , The code is as follows
import pandas as pd
import streamlit as st
from st_aggrid import AgGrid
st.set_page_config(page_title=" Net flight (Netflix) Film data analysis ", layout="wide")
st.title(" Net flight (Netflix) Film data analysis ")
shows = pd.read_csv("netflix_titles.csv")
AgGrid(shows)output

We and st.dataframe(shows) Compared with the results , Discovery call streamlit-aggrid The table displayed by the module is more beautiful , As shown in the figure below
Comparison of results of different methods


Of course, we can also sort the data , As shown in the figure below

And you can also filter the data according to the specified conditions , As shown in the figure below

We can also drag and drop the data of each column in the table according to our preferences , Adjust the order of the tables

More operations
Page turning
In addition to the above basic operations ,streamlit-aggrid The table data displayed by the module also supports page turning , The code is as follows
import pandas as pd
import streamlit as st
from st_aggrid import AgGrid
from st_aggrid.grid_options_builder import GridOptionsBuilder
st.set_page_config(page_title=" Net flight (Netflix) Film data analysis ", layout="wide")
st.title(" Net flight (Netflix) Film data analysis ")
shows = pd.read_csv("netflix_titles.csv")
gb = GridOptionsBuilder.from_dataframe(shows)
gb.configure_pagination()
gridOptions = gb.build()
AgGrid(shows, gridOptions=gridOptions)output

Grouping statistics
We are usually in Pandas Used in the module groupby Group statistics streamlit-aggrid Modules can also be easily implemented , The code is as follows
import pandas as pd
import streamlit as st
from st_aggrid import AgGrid
from st_aggrid.grid_options_builder import GridOptionsBuilder
st.set_page_config(page_title=" Net flight (Netflix) Film data analysis ", layout="wide")
st.title(" Net flight (Netflix) Film data analysis ")
shows = pd.read_csv("netflix_titles.csv")
gb = GridOptionsBuilder.from_dataframe(shows)
gb.configure_pagination()
gb.configure_side_bar()
gb.configure_default_column(groupable=True, value=True, enableRowGroup=True, aggFunc="sum", editable=True)
gridOptions = gb.build()
AgGrid(shows, gridOptions=gridOptions, enable_enterprise_modules=True)such , The toolbar will appear on the far left of the table , We can further operate in it , As shown in the figure below

Highlight table data
stay Pandas In the module, we can highlight the specified data , So in the same way streamlit-aggrid Modules can also be implemented , The code is as follows
shows = pd.read_csv("netflix_titles.csv")
gb = GridOptionsBuilder.from_dataframe(shows)
cellsytle_jscode = JsCode(
"""
function(params) {
if (params.value.includes('United States')) {
return {
'color': 'white',
'backgroundColor': 'red'
}
} else {
return {
'color': 'black',
'backgroundColor': 'white'
}
}
};
"""
)
gb.configure_column("country", cellStyle=cellsytle_jscode)
gridOptions = gb.build()
data = AgGrid(
shows,
gridOptions=gridOptions,
enable_enterprise_modules=True,
allow_unsafe_jscode=True
)We call the country “ The United States ” The movie data of is highlighted in red , As shown in the figure below

The link to get the dataset is :https://www.kaggle.com/datasets/shivamb/netflix-shows?resource=download
NO.1
Previous recommendation
Historical articles
How to get millions of likes ? use Python Making Tiktok video turned out to be so simple !
When Python Let's also repair the artifact , It's really easy to use !!
【 Hard core dry goods 】 Which company is better in data analysis ? choose Pandas Or choose SQL
Share 、 Collection 、 give the thumbs-up 、 I'm looking at the arrangement ?




边栏推荐
- 不会吧?钉钉都下载了,你还不知道可以这样玩?
- Wechat hotel reservation applet graduation project (8) graduation project thesis template
- 如何在 PHP 应用程序中预防SQL 注入
- Wechat campus second-hand book trading applet graduation design finished product (1) development outline
- 局域网SDN技术硬核内幕 - 16 三 从物到人 园区用户漫游的EVPN实现
- 初出茅庐的小李第110篇博客之详细剖析STM32中__NVIC_SetPriorityGrouping(uint32_t PriorityGroup)函数
- zabbix agent创建监控项
- CPU/GPU(CUDA)版本的 YOLOv5后处理代码
- Here comes the genuine Adobe software! Adobe's only genuine family bucket subscription in the world costs only 0 yuan / year
- golang--module
猜你喜欢

Patrick McHardy事件对开源社区的影响

Copytexture, copytoresolvetarget of UE4 engine

21 -- 除自身以外数组的乘积

FTXUI基础笔记(hello world)

Mysql的索引为什么用B+树而不是跳表?

微信小程序项目实战

Information system project managers must recite the core examination points (49) contract law

I use the factory mode in jd.com and explain the factory mode clearly

Alibaba Cloud Security Center's best practices for vulnerability repair

Small program completion work wechat campus second-hand book trading small program graduation design finished product (2) small program function
随机推荐
Graduation project ----- Internet of things environment detection system based on stm32
初出茅庐的小李第111篇博客之中英文点阵字符显示原理
【翻译】宣布Krius--加速你对Kubernetes的监控采用
1.10 API 和字符串
LeetCode(剑指 Offer)- 11. 旋转数组的最小数字
局域网SDN技术硬核内幕 8 从二层交换到三层路由
船新 IDEA 2022.2 正式发布,新特性真香
Talk about 12 business scenarios of concurrent programming
Scala main constructor_ Scala main constructor depth
“蔚来杯“2022牛客暑期多校训练营1 (部分题目总结)
[record of question brushing] 18. Sum of four numbers
2022年暑假ACM热身练习4(总结)
【第31天】给定一个整数 n ,求出它的每个质因数的底数与指数 | 算术基本定理
成功解决:error: src refspec master does not match any
21 -- 除自身以外数组的乘积
船舶测试/ IMO A.799 (19)船用结构材料不燃性试验
【无标题】
VMware 中搭建 SylixOS 环境
Alibaba Cloud Security Center's best practices for vulnerability repair
主题域模型