我有一个DataFrame
.两个相关列如下:一列是列,int
另一列是列str
.
我明白,如果我插入NaN
到int
列,熊猫将全部转化int
成float
因为没有NaN
一个值int
.
然而,当我插入None
到str
列,熊猫都转换我int
来float
为好.这对我来说没有意义 - 为什么第2列中的值会影响第1列?
这是一个简单的工作示例(Python 2):
import pandas as pd
df = pd.DataFrame()
df["int"] = pd.Series([], dtype=int)
df["str"] = pd.Series([], dtype=str)
df.loc[0] = [0, "zero"]
print df
print
df.loc[1] = [1, None]
print df
Run Code Online (Sandbox Code Playgroud)
输出是
int str
0 0 zero
int str
0 0.0 zero
1 1.0 NaN
Run Code Online (Sandbox Code Playgroud)
有没有办法使输出如下:
int str
0 0 …
Run Code Online (Sandbox Code Playgroud) 我试图在MATLAB中绘制3D曲面,并且我使用了meshgrid
,类似于MATLAB教程在这里所说的:http://www.mathworks.com/help/matlab/ref/meshgrid.html
我写了一个非常简单的三行脚本,我认为它会产生表面z = x + y,它如下:
[x , y] = meshgrid( linspace( 0 , 10 , 10 ) , linspace( 0 , 10 , 10 ) );
z = x + y;
surf( [ x , y , z] );
Run Code Online (Sandbox Code Playgroud)
根据我的理解,第1行产生(x,y)坐标的所有组合,从0到10均匀间隔.然后第2行将公式z = x + y
应用于该详尽的组合列表.然后第3行只绘制所有(x, y, z)
点.
但我得到以下"东西"作为输出:
我很确定上图中的图形不是z = x + y
,我不知道为什么没有两个轴上升到最大值10.
尽管如此,我发现脚本太简单了,看不出有什么问题.任何人都可以指出我忽略了什么吗?谢谢.
我有198px-198px的方形按钮.每个按钮下面都有一个图像和文字.由于并非所有图像都是正方形,因此我将所有图像的最大宽度和最大高度设置为128px,以便它们按比例缩放.不幸的是,我无法将文本与底部中心对齐.
我无法使用padding-top: 65px
哪个解决了其他一些SO问题,因为图像的高度可变.
我尝试position: absolute; top: 180px
了文本的范围,但我不能让它在那之后居中(不能只指定left: 10px
因为文本有可变的长度)
谢谢你的帮助.
这是一个JSFiddle https://jsfiddle.net/vbgg3keu/3/ (注意:您可以扩展输出窗格的宽度,以便所有按钮在同一行上排成一行)
HTML:
<button class="square-button">
<img class="small-img" src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"/><br/>
<span class="button-text">This text is too high</span>
</button>
<button class="square-button">
<img class="small-img" src="http://etc.usf.edu/clipart/36400/36459/ruler1_36459_lg.gif"/><br/>
<span class="button-text">This text is too high</span>
</button>
<button class="square-button">
<img class="small-img" src="https://tall.life/wp-content/uploads/2013/04/Giraffe.jpg"/><br/>
<span class="button-text">This text is the correct height</span>
</button>
<button class="square-button">
<img class="small-img" src="https://lh3.googleusercontent.com/dB3Dvgf3VIglusoGJAfpNUAANhTXW8K9mvIsiIPkhJUAbAKGKJcEMPTf0mkSexzLM5o=w300"/><br/>
<span class="button-text">This text is the correct height</span>
</button>
Run Code Online (Sandbox Code Playgroud)
CSS:
.square-button {
width: 198px;
height: 198px;
float: left;
}
.small-img …
Run Code Online (Sandbox Code Playgroud)