把“商品价格”列小于0.08的数值修改为0,并输出为新的文件 import pandas as pd df = pd.read_excel("AAA.xlsx") df.loc[df['商品价格'] < 0.08, '商品价格'] = 0 print(df) df.to_excel('newAAA. ...
分类:
其他好文 时间:
2019-11-15 20:20:11
阅读次数:
187
1 两个Dataframe相加时,一定要注意索引是否对应再相加,利用这个特点有时可以先用set_index()将某些列置为索引列,再进行相加. import pandas as pd df1 = pd.DataFrame({'a':np.arange(1,5,1), 'b':np.arange(3, ...
分类:
其他好文 时间:
2019-11-15 14:13:54
阅读次数:
99
import pandas as pd # 0 读取数据 df = pd.read_csv("文件路径")#例子是北京一年的天气情况 df.head()#查看表头 # 设定索引为日期,方便按日期进行查询 df.set_index('ymd',inplace = True) print("df.ind ...
分类:
其他好文 时间:
2019-11-13 11:26:42
阅读次数:
944
from datetime import date, datetime, timedelta import time import pandas as pd from pandas.tseries.offsets import Hour, Minute, Second print(time.loca ...
分类:
其他好文 时间:
2019-11-12 20:12:44
阅读次数:
750
select count(1) from pd_xxx_origin_xxx_data where create_time like '2019-02-23%' and source='20036' SELECT sum(case when create_time like '2019-02-23% ...
分类:
数据库 时间:
2019-11-12 20:08:07
阅读次数:
84
import pandas as pd from datetime import datetime fn = r"D:\OneDrive - UNSW\tweets_flu.csv" df = pd.read_csv(fn) for i in range(len(df)): t = df.iloc[... ...
分类:
其他好文 时间:
2019-11-10 15:58:16
阅读次数:
112
时间序列 索引 / 切片 / 重采样 时间序列 👉 索引 # 示例数据 import numpy as np import pandas as pd import datetime times = pd.date_range('2019-1-1',periods=10,freq='MS') ps ...
分类:
编程语言 时间:
2019-11-08 22:31:38
阅读次数:
184
1、pd.set_option('expand_frame_repr', False) True就是可以换行显示。设置成False的时候不允许换行 2、pd.set_option('display.max_rows', 10) pd.set_option('display.max_columns', ...
分类:
编程语言 时间:
2019-11-07 11:37:37
阅读次数:
129
Pandas 时刻数据 / 时间戳索引 / 时期对象 时刻数据 TimeStamp 👇 时刻数据 代表时间点,是Python的数据类型 pandas.Timestamp 是一个时间戳 import pandas as pd import datetime as dt Timestamp 的创建 , ...
分类:
编程语言 时间:
2019-11-07 10:03:26
阅读次数:
116
导入数据pd.read_csv(filename):从CSV文件导入数据pd.read_table(filename):从限定分隔符的文本文件导入数据pd.read_excel(filename):从Excel文件导入数据pd.read_sql(query,connection_object):从SQL表/库导入数据pd.read_json(json_string):从JSON格式的字符串导入数据
分类:
其他好文 时间:
2019-11-06 10:30:14
阅读次数:
132