摘要:
要实现这个功能,可能有多种方法,我在这里记录下一个比较方便的方法: import pandas as pd writer = pd.ExcelWriter('test.xlsx') data1.to_excel(writer,sheet_name='sheet1') data2.to_excel(w 阅读全文
posted @ 2022-09-15 22:14
shclbear
阅读(1061)
评论(0)
推荐(0)
摘要:
# 通过正则表达式,给key加上引号# content = re.sub(r'(?<={|,)([a-zA-Z][a-zA-Z0-9]*)(?=:)', r'"\1"', content) # 新数据已经有引号了 阅读全文
posted @ 2022-09-14 00:50
shclbear
阅读(45)
评论(0)
推荐(0)
摘要:
#判断变量类型的函数 def typeof(variate): type=None if isinstance(variate,int): type = "int" elif isinstance(variate,str): type = "str" elif isinstance(variate, 阅读全文
posted @ 2022-09-13 23:55
shclbear
阅读(61)
评论(0)
推荐(0)
摘要:
1. 带标签的Series import pandas as pd import numpy as np # Series s = pd.Series([1,3,6,np.nan,44,1]) print(s) s = pd.Series([1,3,6,np.nan,44,1],index=[3,4 阅读全文
posted @ 2022-09-13 17:35
shclbear
阅读(47)
评论(0)
推荐(0)
摘要:
原数据 运行结果 结果出现异常 修改代码 运行结果成功 成功转成时间: 阅读全文
posted @ 2022-09-12 21:24
shclbear
阅读(224)
评论(0)
推荐(0)
摘要:
Pandas中进行数据类型转换有二种基本方法: 使用astype()函数进行强制类型转换使用Pandas提供的函数如to_numeric()、to_datetime()1.使用astype()函数进行强制类型转换1.1转float类型 df['金额'].astype('float') 1.2转int 阅读全文
posted @ 2022-09-12 17:03
shclbear
阅读(1146)
评论(0)
推荐(0)
摘要:
解决方案:可能开启了节流模式,如下图切换回来即可。 阅读全文
posted @ 2022-09-11 21:17
shclbear
阅读(576)
评论(0)
推荐(0)
摘要:
腾讯财经接口 以五粮液为例,要获取最新行情,访问数据接口: qt.gtimg.cn/q=sz000858 返回数据: v_sz000858="51~五 粮 液~000858~27.78~27.60~27.70~417909~190109~227800~27.78~492~27.77~332~27.7 阅读全文
posted @ 2022-09-10 18:34
shclbear
阅读(1665)
评论(0)
推荐(0)
摘要:
read_csv的时候加一个参数:parse_dates = ['date'],就会把date这一列自动转化为日期格式,例如 file_path = root_path + "/data/stock_data.csv" data = pd.read_csv(file_path, header = 0 阅读全文
posted @ 2022-09-10 14:31
shclbear
阅读(1175)
评论(0)
推荐(0)
摘要:
解决to_hdf() 报错ImportError: Missing optional dependency ‘tables‘. Use pip or conda to install tables. 解决方法 conda install pytables 1 或是: pip install tabl 阅读全文
posted @ 2022-09-10 10:29
shclbear
阅读(1081)
评论(0)
推荐(0)