pd

iText 7 : This pdf document might not be displayed correctly Firefox

梦想与她 提交于 2021-02-05 06:39:46
问题 I am running into strange issue with generated pdf's from iText7 . The generated pdf's are opening properly in Adobe reader and Chrome browser . But the same pdf is opening partially in the Firefox browser. I am getting the below message in Firefox. The strange thing is other pdf, which are not generated via iText are properly rendering in firefox. Java code public static byte[] createPdf(List<String> htmlPages, PageSize pageSize, boolean rotate) throws IOException { ConverterProperties

【Pandas】合并DataFrame

感情迁移 提交于 2020-03-09 04:58:40
1.创建DataFrame df1 = pd . DataFrame ( np . arange ( 0 , 12 ) . reshape ( 3 , 4 ) , columns = [ "A" , "B" , "C" , "D" ] ) df2 = pd . DataFrame ( np . arange ( 12 , 24 ) . reshape ( 3 , 4 ) , columns = [ "A" , "B" , "C" , "D" ] ) 2.直接合并 # pd.concat(),axis为0是纵向合并,为1是横向合并,ignore_index是否忽略索引 new_df = pd . concat ( [ df1 , df2 ] , axis = 0 , ignore_index = True ) print ( new_df ) # 输出结果: # A B C D # 0 0 1 2 3 # 1 4 5 6 7 # 2 8 9 10 11 # 3 12 13 14 15 # 4 16 17 18 19 # 5 20 21 22 23 3.outer、inner合并 df3 = pd . DataFrame ( np . arange ( 0 , 12 ) . reshape ( 3 , 4 ) , columns = [ "A" , "B" , "C" , "F" ]

15-pandas与numpy加法差异

倾然丶 夕夏残阳落幕 提交于 2020-03-09 02:15:26
import numpy as np import pandas as pd a=np.array([1,2,3]) b=np.array([3]) print(a+b)#[4 5 6] 只要列一致,广播,每个都加 s=pd.Series([1,2,3,4]) print(s+1)#Series与数组的假发,每个都加 s2=pd.Series([2]) print(s+s2)#仅匹配一个 print(s.add(s2,fill_value=0))#仅匹配一个,其余加0 df1=pd.DataFrame({"A":[1,2,3], "B":[7,8,9]}) df2=pd.DataFrame({"B":[1,2,3], "C":[7,8,9]}) print(df1.add(df2))#匹配的相加,不匹配的NaN print(df1.add(df2,fill_value=0))#匹配的相加,其余加0    来源: https://www.cnblogs.com/wcyMiracle/p/12446253.html

11-pandas拼接

余生颓废 提交于 2020-03-09 00:52:38
import numpy as np import pandas as pd x=np.array([1,2,3]).reshape(1,3)#调节形状为二维数组 y=np.array([4,5,6]).reshape(1,3) z=np.array([7,8,9]).reshape(1,3) print(np.concatenate([x,y,z]))#numpy二维数组的拼接 arr1=np.random.randn(4,4) np.concatenate([arr1,arr1])#横着拼接 np.concatenate([arr1,arr1],axis=1)#竖着拼接 def make_dataFrame(cols,ind): data={c:[str(c)+str(i) for i in ind] for c in cols} return pd.DataFrame(data,ind) print(make_dataFrame("abc",range(3))) df1=make_dataFrame("AB",[1,2]) df2=make_dataFrame("AB",[3,4]) print(pd.concat([df1,df2])) print(pd.concat([df1,df2],ignore_index=True))#覆盖原索引,重建索引 print(pd

pandas vs excel学习笔记

久未见 提交于 2020-03-04 02:59:46
# - * - coding : utf - 8 - * - import pandas as pd import numpy as np # 1 ##### 1.1 创建一个dataframe并保存为excel文件 # === === === === === === === === === === === === === === === === === === === === === === === === === == # df = pd . DataFrame ( { 'id' : [ 1 , 2 , 3 ] , 'name' : [ 'a' , 'b' , 'c' ] } ) # df = df . set_index ( 'id' ) # df . to_excel ( 'e:/output-f.xlsx' ) # === === === === === === === === === === === === === === === === === === === === === === === === === == # 2 # === === === === === === === === === === === === === === === === === === === === === === === === === == # people = pd . read

python基础教程:通过Turtle库在Python中绘制一个鼠年福鼠

一曲冷凌霜 提交于 2020-02-29 00:04:05
这篇文章主要介绍了通过Turtle库在Python中绘制一个鼠年福鼠,本文通过实例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下 turtle库是一个很经典的绘图库,其最初来自于1967年创造的logo编程语言,之后被Python编写放到了Python的内置模块中。网络上有很多借助于turtle绘制精美图像的案例。比如小猪佩奇、皮卡丘、柯基犬等等。趁着新年假期还未结束,今天州的先生(https 文章目录 一、绘制鼠头 二、绘制身体 三、绘制手 四、绘制帽子 五、绘制尾巴 一、绘制鼠头 首先,咱们(https://zmister.com)把鼠的头给绘制了。鼠头主要是由圆来构成,脸庞是一个大圆,耳朵、眉毛、眼睛、嘴角和鼻子也都是由不同弧度的圆构成。鼠头的绘制代码如下所示: def head ( ) : turtle.color ( 'black' ) # 脸轮廓 turtle.pd ( ) # 落笔 turtle.circle ( 50 ) # 画一个半径为50的圆 turtle.pu ( ) # 提笔 # 右耳轮廓 turtle.goto ( 50,60 ) # 移动到x=50,y=60的位置 turtle.pd ( ) # 落笔 turtle.circle ( 30,260 ) # 画一个半径为30,角度为245的圆弧 turtle.pu ( ) # 提笔

[Python Cookbook]Pandas: How to increase columns for DataFrame?Join/Concat

醉酒当歌 提交于 2020-02-28 05:26:50
1. Combine Two Series series1=pd.Series([1,2,3],name='s1') series2=pd.Series([4,5,6],name='s2') df = pd.concat([series1, series2], axis=1) Out: series1=pd.Series([1,2,3],index=['a','b','c'],name='s1') series2=pd.Series([4,5,6],index=['a','b','d'],name='s2') df = pd.concat([series1, series2], axis=1) Out: Note: Two series must have names. 2. Add a series to a data frame df=pd.DataFrame([1,2,3],index=['a','b','c'],columns=['s1']) s2=pd.Series([4,5,6],index=['a','b','d'],name='s2') df['s2']=s2 Out: This method is equivalant to left join: d2.join(s2,how='left',inplace=True) To get the same result

pandas中DataFrame行、列显示不全解决方法

与世无争的帅哥 提交于 2020-02-26 17:17:28
pandas中DataFrame行、列显示不全解决方法 import pandas as pd #显示所有列(参数设置为None代表显示所有行,也可以自行设置数字) pd.set_option('display.max_columns',None) #显示所有行 pd.set_option('display.max_rows',None) #设置数据的显示长度,默认为50 pd.set_option('max_colwidth',200) #禁止自动换行(设置为Flase不自动换行,True反之) pd.set_option('expand_frame_repr', False)    来源: https://www.cnblogs.com/yoyo1216/p/12367713.html

【搬砖】【Python数据分析】Pycharm中plot绘图不能显示出来

穿精又带淫゛_ 提交于 2020-02-16 09:35:08
  最近在看《Python数据分析》这本书,而自己写代码一直用的是Pycharm,在练习的时候就碰到了plot()绘图不能显示出来的问题。网上翻了一下找到知乎上一篇回答,试了一下好像不行,而且答住提供的“from pylab import *”的方法也不太符合编程规范,最后在Stackoverflow找到了想要的答案,特在此分析一下给大家: 以下是 有问题的代码,不能绘图成功 : import pandas as pd from numpy import * import matplotlib.pyplot as plt ts = pd.Series(random.randn(1000), index=pd.date_range('1/1/2000', periods=1000)) ts = ts.cumsum() ts.plot() 解决方案是:导入matplotlib.pyplot库,绘图后再调用matplotlib.pyplot.show()方法就能把绘制的图显示出来了! 如下(注:后面发现此方法在知乎上那篇问答的评论区有人提供了): import pandas as pd from numpy import * import matplotlib.pyplot as plt ts = pd.Series(random.randn(1000), index=pd.date

PyQt5_QProgressDialog_进度对话框

霸气de小男生 提交于 2020-02-11 19:53:00
QProgressDialog 进度对话框,向用户提示当前程序的进度信息,演示当前程序正在进行,向用户提供终止操作的机会。 from PyQt5 . Qt import * class MyWindow ( QWidget ) : def __init__ ( self ) : super ( ) . __init__ ( ) self . setWindowTitle ( 'QProgressDialog' ) self . resize ( 500 , 500 ) self . iniUI ( ) def iniUI ( self ) : pd = QProgressDialog ( self ) ##########################默认情况下 四秒钟之后会自动弹出进度对话框,满值自动关闭 ########################## 窗口级别的模态窗口open()弹出 pd . setValue ( 95 ) pd . setMinimumDuration ( 1000 ) # 一秒钟之后自动弹出进度对话框 pd . setAutoClose ( True ) # 取消满值自动关闭(默认情况下满值自动重置 ) pd . setAutoReset ( True ) # 取消自动重置 (默认情况下满值自动重置 ) pd . setLabelText (