当前位置:网站首页>Dataframe sorting: datetime format splitting; Delete a specific line; Group integration.
Dataframe sorting: datetime format splitting; Delete a specific line; Group integration.
2022-07-26 03:06:00 【Ten at eight】
Import CSV Format data , And separate the month, year and day .
take csv Import format data as dataframe Format .
also , take date columne Split on the day of .
First, make sure date columne The format in is datetime Format .
import pandas as pd
#pd.set_option('display.max_rows', None)
df = pd.read_csv(r"D:\xxx.csv",parse_dates=["date"])
df["year"] = df.date.apply(lambda x:x.year)
df["month"] = df.date.apply(lambda x:x.month)
df["day"] = df.date.apply(lambda x:x.day)
Delete specific lines
Put one in each line columne If 0, Then delete the line .
df=df.drop(df[df["xxx"] == 0].index)
Group by year and month
Use groupby function . And for size columne In sum .
month_size = df["size"].groupby([df["year"],df["month"]]).sum()
day_size = df["size"].groupby([df["year"],df["month"],df["day"]]).sum()
边栏推荐
- Usage of fuser and lsof
- How can users create data tables on Web pages and store them in the database
- How about GF Securities? Is it safe to open an account online?
- Swin Transformer【Backbone】
- snownlp库各功能及用法
- c语言分层理解(c语言函数)
- 持续交付和DevOps是一对好基友
- Nahamcon CTF 2022 babyrev reverse analysis
- STM32——DMA笔记
- Information system project managers must recite the core examination site (50). The contract content is not clearly stipulated
猜你喜欢

My friend took 25koffer as soon as he learned automation test. When will my function test end?

STM——EXTI外部中断学习笔记

如何根据登录测试的需求设计测试用例?

案例:使用keepalived+Haproxy搭建Web群集
![[steering wheel] use the 60 + shortcut keys of idea to share with you, in order to improve efficiency (reconstruction)](/img/b4/62a4c06743fdedacdffd9b156a760f.png)
[steering wheel] use the 60 + shortcut keys of idea to share with you, in order to improve efficiency (reconstruction)

Detailed explanation of extended physics informedneural networks paper

复制列表时踩过的坑:浅拷贝与深拷贝

Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 1)

在混合云中管理数据库:八个关键注意事项

循环与分支(一)
随机推荐
Anti electronic ink screen st7302
Three years of software testing experience, salary has been stuck at 10K, how to improve and develop automated testing?
ES6 set and map
Win11更改磁盘驱动器号的方法
Swin Transformer【Backbone】
对于稳定性测试必需关注的26点
Image recognition (VII) | what is the pooling layer? What's the effect?
图像识别(七)| 池化层是什么?有什么作用?
How can users create data tables on Web pages and store them in the database
Standardize your own debug process
[translation] announce Vites 13
FPGA_Vivado软件初次使用流程_超详细
STM32——串口学习笔记(一个字节、16位数据、字符串、数组)
Design of golang lottery system
Longest Substring Without Repeating Characters
STM——EXTI外部中断学习笔记
Keyboardtraffic, a tool developed by myself to solve CTF USB keyboard traffic
Be highly vigilant! Weaponization of smartphone location data on the battlefield
Detailed explanation of extended physics informedneural networks paper
多线程编程