
pandas
fK0pS
女朋友每天催着我写博客
展开
-
Python 读xlsx文件
pip install openpyxledata = pd.read_excel(excel)原创 2021-12-03 23:17:03 · 835 阅读 · 0 评论 -
Python 重命名 文件夹
# 这个脚本是将r'Y:\Project\SCD\SDVDS\VFDVD-Rename'下的d号文件名,重命名为'2021-04-07--0031-P1'rootPath = r'Y:\Project\VDFVD\rVDF00DFVD030\VV-Rename'excel = r'Y:\Project\VDFVD\r00VFDV030\VDFVF数据.xlsx'import osimport pandas as pdlsDir = os.listdir(rootPath)edata =.原创 2021-12-03 23:16:13 · 1552 阅读 · 0 评论 -
使用numpy和pandas构造随机数
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltdef getData(): r""" 使用numpy构造满足条件的随机数() :return: """ dataX = np.random.randint(1,100,size=(1,100)) dataY = np.random.randint(1,100,size=(1,100)) data = ...原创 2021-08-05 15:58:29 · 2227 阅读 · 0 评论 -
对pandas中的数据进行随机抽样
方案1https://www.jianshu.com/p/5cf2abe4385c方案2:https://www.pythonf.cn/read/91137方案3:x_train, x_test, y_train, y_test = train_test_split(data, label, test_size=0.15, ramdon_state=0)原创 2021-07-28 16:16:30 · 714 阅读 · 0 评论 -
python -m 是什么指令
介绍的还是挺详细的。原创 2021-06-06 16:19:58 · 146 阅读 · 0 评论 -
Python 两个numpy 的一维数组如何拼到一起呢?
Before = np.arange(range[0]-frame*n, range[0], n)During = np.arange(range[0], range[1], n)After = np.arange(range[1], range[1]+frame*n, n)Total = np.hstack((Before, During, After))原创 2021-06-04 14:08:37 · 1507 阅读 · 0 评论 -
为什么pycharm的jupyter的debug没有 debug python consle(用起来真不方便啊)
为什么pycharm的jupyter的debug没有 debug python consle(用起来真不方便啊)坑已经反馈给anna了。希望他们能早日解决。原创 2021-06-02 16:06:55 · 207 阅读 · 0 评论 -
pandas读有index的csv.
https://blog.youkuaiyun.com/u011412768/article/details/109522349这篇博客总结的非常仔细。非常好!原创 2021-06-02 13:48:02 · 163 阅读 · 0 评论 -
pandas 转置
newdf = pd.DataFrame(data = df.value.T)原创 2021-06-01 12:35:30 · 274 阅读 · 0 评论 -
subplots 和 subplot的区别
https://blog.youkuaiyun.com/weixin_43828405/article/details/92801613推荐使用subplots原创 2021-06-01 10:59:52 · 1052 阅读 · 0 评论 -
Python pandas 重置data frame的index
N09_0027_P1 = N09_0027_P1.reset_index(drop=True)原创 2021-06-01 10:44:46 · 436 阅读 · 0 评论 -
numpy 转 list
原创 2021-05-31 23:07:43 · 602 阅读 · 0 评论 -
pandas的subplot添加legend
https://matplotlib.org/stable/tutorials/intermediate/legend_guide.html#sphx-glr-tutorials-intermediate-legend-guide-py原创 2021-05-31 22:24:23 · 1239 阅读 · 0 评论 -
pandas的subplot
N09_0027_P1['mean pupil'].plot(xlabel='date', ylabel='pupil size', kind='line', title='N09_0027_P1',ax = plt.subplot(411))N09_0027_P2['mean pupil'].plot(xlabel='date', ylabel='pupil size', kind='line', title='N09_0027_P2',ax = plt.subplot(412))N09_0027_.原创 2021-05-31 21:41:19 · 775 阅读 · 0 评论 -
pandas plot 某一列 (pandas plot column)
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.plot.html请看如上的文档plt.figure()N30_0032_P4['mean pupil'].plot(xlabel='date',ylabel='pupil size',kind = 'line', title = 'N30_0032_P4')plt.show()N30_0032_P3['mean pupil'].pl.原创 2021-05-31 21:23:59 · 1206 阅读 · 0 评论 -
pandas 按照列值进行模糊查询
N09_P1 = dfResults.loc[dfResults['des'].isin(['0027-P1'])] #绝对查询found = dfResults.loc[dfResults['des'].str.contains('0027-P1')]#模糊查询原创 2021-05-31 20:53:35 · 3750 阅读 · 0 评论 -
pandas 根据列条件 模糊查询
search = ['python','java','go'] found = [s['language].str.contains(x) for x in searchfor]原创 2021-06-18 09:06:01 · 682 阅读 · 0 评论 -
pandas根据某一列的内容进行索引
https://www.cnblogs.com/zmc940317/p/13615168.html这个博客总结的非常好。# 选取某列是否是某一类型的数值 用 isindf.loc[df['column_name'].isin(some_values)]原创 2021-05-31 20:34:42 · 840 阅读 · 0 评论 -
Python np.random.randint 随机数,指定区间的随机数
原创 2021-05-16 21:03:04 · 847 阅读 · 0 评论 -
Python pandas to csv 如何保存指定列 (根据列名保存csv)
Python pandas to csv 如何保存指定列 (根据列名保存csv)解决方案:一定要有两个列表哦原创 2021-05-14 15:07:36 · 2259 阅读 · 0 评论 -
pandas 如何计算两个 series 之间的相关性
pandas 如何计算两个 series 之间的相关性how to calculate the correlation bewteen twoseriesgoogle yyds原创 2021-05-14 15:01:43 · 1747 阅读 · 0 评论 -
pandas how to understand axis =0 or axis = 1
比方说我有一个需求:新添加一列?---那么用的应该是axis = 1dfData2['PupilSize'] = dfData2.apply(calPupilSize, axis=1)这样理解:新添一列,那么之前所有列都参与计算了。或者,新添加一行? axis = 0NaCl0_9dfDataMean = NaCl0_9dfData.mean(axis=0)上边的内容太难记忆了,怎么想一个好的比喻呢?看0,相当于把所有的行给圈住了。比如...原创 2021-05-14 14:24:09 · 105 阅读 · 0 评论 -
pandas 所有行取平均
直接调用pd的函数,然后指定行、列原创 2021-05-14 13:51:06 · 2488 阅读 · 0 评论 -
python读csv 第一列是index。如何读,才能把第一列当成index
NaCl12dfData5 = pd.read_csv(NaCl12FilePath,index_col = 0)在csv中 第一列是index如果csv中没有列名,该怎么办?header = None原创 2021-05-14 13:46:02 · 894 阅读 · 0 评论 -
python pandas 修改列名
https://www.jb51.net/article/137888.htm还有其他若干方法。原创 2021-05-12 10:47:28 · 543 阅读 · 0 评论 -
pandas只把某一列的值存成csv(header=None index =False)
坑index=False原创 2021-04-07 13:06:25 · 632 阅读 · 0 评论 -
plt legned的名字如何指定
label = 'line'l1, = plt.plot(x, y1, label = 'line')plot的时候设置lablel2, = plt.plot(x, y2, label = 'parabola', color = 'red', linewidth = 1.0, linestyle = '--')原创 2021-04-06 22:48:32 · 364 阅读 · 0 评论 -
plot.line 加个title, 加个图标legend,X轴,Y轴标签
plot.line 加个title, 加个图标legendbodyPart1['dis'].plot.line(style = 'r')bodyPart2['dis'].plot.line(style = 'g')bodyPart3['dis'].plot.line(style = 'b')ax = bodyPart4['dis'].plot.line()ax.set_xlabel('Frame')plt.legend(loc='best')plt.show()...原创 2021-04-06 22:25:19 · 866 阅读 · 0 评论 -
help(pd.DataFrame.plot) 某一列绘制成曲线图
help(pd.DataFrame.plot)lines = bodyPart1['dis'].plot.line(x='pig', y='horse')参考:https://blog.youkuaiyun.com/h_hxx/article/details/90635650我的问题,(1)如何使用?(2)如何有效记住?df.plot.line()参考:https://blog.youkuaiyun.com/h_hxx/article/details/9...原创 2021-04-06 22:12:26 · 877 阅读 · 0 评论 -
pandas每一列都执行相同的函数
pandas每一列都执行相同的函数apply函数。我的需求:(1)第三列,是第一列和第二列的平方和,开根号。df['TotalScore'] = df['Score'] + df['ExtraScore'] #只能用加法...因为加法运算符被重载过了。好像这种句式就可以。不行!!!必须得用apply函数def calDistance(df): print(df) a = bodyPart1['x'] b = ...原创 2021-04-06 21:41:05 · 2060 阅读 · 0 评论 -
pandas ‘utf-8‘ codec can‘t decode bytes in position 49914-49915: invalid continuation byte
用excel打开csv,把中文字符删了。然后另存为csv-utf的格式。就好了原创 2021-03-16 10:24:06 · 253 阅读 · 0 评论 -
pandas 向量拼接 (一定要用上ignore_index = True)
oneVector2 = pd.DataFrame(data =np.random.random((1,3)))oneVector1 = pd.DataFrame(data =np.random.random((1,3)))按照“行”进行拼接:ccc = pd.concat([oneVector1,oneVector2],axis =0,ignore_index = True)如何对列进行拼接呢?ccc = pd.concat([oneVector1,...原创 2021-01-25 22:54:42 · 12060 阅读 · 1 评论 -
dfDate.to_csv如何覆盖掉原来的csv文件
timeStr = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) + "-" + PMStr + "-Report.csv"dfDate3.to_csv(timeStr,mode="w")原创 2021-07-01 09:10:27 · 1445 阅读 · 0 评论 -
pandas中的Series获取里边的值
r.values[0]原创 2021-01-20 18:48:26 · 3479 阅读 · 0 评论 -
pandas求矩阵的逆
结论是用numpy,然后重新转换成pandas原创 2021-01-14 18:01:10 · 1446 阅读 · 0 评论 -
PANDAS向量点乘
X.T.dot(X)原创 2021-01-14 17:58:28 · 1627 阅读 · 0 评论 -
pandas 转成int
df.astype("int")原创 2021-01-09 15:45:01 · 2746 阅读 · 0 评论 -
BI是什么缩写?
BI是Business Intelligence(BI)数据分析一般分为三个层面:(1)Memory内存分析层面(2)BI分析层面(3)Massive分析层面原创 2020-10-29 14:17:52 · 2561 阅读 · 0 评论 -
Python 绘制直方图,numpy数据类型绘制直方图
Python 绘制直方图plt.hist(h)plt.show()rNumpyprint('axis sum',rNumpy.sum(axis=1))#每个客户一共用的代数h = rNumpy.sum(axis=1)num_bins = 300#一共135个人plt.hist(h,num_bins, facecolor='blue', alpha=0.5)plt.show()#只统计1~100的...原创 2020-10-28 23:47:27 · 2178 阅读 · 0 评论 -
对Numpy进行按行求和
原创 2020-10-28 23:31:57 · 16041 阅读 · 0 评论