在数据框架中,我从1951年到2007年按国家/地区划分了一个平衡的面板.我想将其转换为我的其他变量的五年平均值的新数据框架.当我坐下来做这个时,我意识到我能想到的唯一方法是做一个for循环,然后决定是时候来stackoverflow寻求帮助了.
那么,是否有一种简单的方法来转换如下所示的数据:
country country.isocode year POP ci grgdpch
Argentina ARG 1951 17517.34 18.445022145 3.4602044759
Argentina ARG 1952 17876.96 17.76066507 -7.887407586
Argentina ARG 1953 18230.82 18.365255769 2.3118720688
Argentina ARG 1954 18580.56 16.982113434 1.5693778844
Argentina ARG 1955 18927.82 17.488907008 5.3690276523
Argentina ARG 1956 19271.51 15.907756547 0.3125559183
Argentina ARG 1957 19610.54 17.028450999 2.4896639667
Argentina ARG 1958 19946.54 17.541597134 5.0025894968
Argentina ARG 1959 20281.15 16.137310492 -6.763501447
Argentina ARG 1960 20616.01 20.519539628 8.481742144
...
Venezuela VEN 1997 22361.80 21.923577413 5.603872759
Venezuela VEN 1998 …Run Code Online (Sandbox Code Playgroud) 我正试图为我的网站创建一种观点人群.它实际上是一个充满平面图像的ul,我想创造一个像圆形人群一样的"弯曲"感觉.它向内并且在内部看起来更小并且朝向末端弯曲.
海报圈示例是我能找到的最接近的http://www.webkit.org/blog-files/3d-transforms/poster-circle.html,除了我不需要"前面" - 只是背面.每幅图像为100px x 100px,每行23幅图像和4行.
关于如何处理这个问题,我几乎完全失去了...我尝试了几种不同的方法,将独特的-webkit-transform:rotateY(x)translateZ(x)应用于每个图像,但从未完全实现(努力计算正确的价值观,或完全使用错误的东西),以及玩视角.
我有以下变换:
Transform /^"([^"]+)" Phase$/ do |name|
# Returns the phase named 'name',
# or raises an exception if it doesn't exist
end
Run Code Online (Sandbox Code Playgroud)
它适用于步骤定义,如下所示:
Then /("(?:[^"]+)" Phase) should do something/ do |phase|
# Should fail if the specified phase doesn't exist
end
Run Code Online (Sandbox Code Playgroud)
我还有以下步骤定义,它使用相同的"([^"]+)" Phase模式:
Given /("([^"]+)" Phase) follows ("([^"]+)" Phase)/ do |pre, post|
# Should create the specified phases
end
Run Code Online (Sandbox Code Playgroud)
如果指定的阶段不存在,我不希望步骤定义失败.我想创建阶段.
我想创建一个转换,它将为我创建一个阶段,以便稍微干掉步骤定义,但我不能这样做,因为我已经拥有上面提到的具有完全相同的正则表达式的转换.
基本上,如果它是一个Given步骤,我想创建阶段,如果不是,我想提出失败.
有任何想法吗?
有没有人知道如何缩放图像但坚持底部?下面是我的代码,我的图像在中间缩放,但我需要它们粘在底部.
.animation_scale{
position:absolute;
top:150px;
left:55px;
display:block;
z-index:-10;
bottom : 0;}
.animation_scale img{
animation-name:animation_scale;
animation-duration:1s;
animation-timing-function:ease;
animation-delay:0s;
animation-iteration-count:1;
animation-direction:alternate;
animation-play-state:running;
animation-fill-mode: forwards;
/* Firefox: */
-moz-animation-name:animation_scale;
-moz-animation-duration:1s;
-moz-animation-timing-function:ease;
-moz-animation-delay:0s;
-moz-animation-iteration-count:1;
-moz-animation-direction:alternate;
-moz-animation-play-state:running;
-moz-animation-fill-mode: forwards;
/* Safari and Chrome: */
-webkit-animation-name:animation_scale;
-webkit-animation-duration:1s;
-webkit-animation-timing-function:ease;
-webkit-animation-delay:0s;
-webkit-animation-iteration-count:1;
-webkit-animation-direction:alternate;
-webkit-animation-play-state:running;
-webkit-animation-fill-mode: forwards;}
@keyframes animation_scale {
0% {
-webkit-transform: scale(0.2) translate(0px);
-moz-transform: scale(0.2) translate(0px);
-o-transform: scale(0.2) translate(0px);}
100% {
-webkit-transform: scale(1.0) skew(0deg) translateY(-10px);
-moz-transform: scale(1.0) skew(0deg) translateY(-10px);
-o-transform: scale(1.0) skew(0deg) translateY(-10px);}}
@-moz-keyframes animation_scale /* Firefox */ …Run Code Online (Sandbox Code Playgroud) 这可能是"你做错了"的经典案例,但我迄今为止所有的搜索都没有得到任何帮助.
这是我的情景:
我正在使用albersUSA地图投影与国家和县GeoJson文件一起绘制所有内容.
我还有一个自创的"城市"文件,其中包含每个州的主要城市.坐标是准确的,一切都很好.

当用户单击给定状态时,我隐藏所有状态形状,然后计算使该状态的县形状适合我的视口所需的变换.然后,我将该变换应用于所有必要的县形状,以获得"缩放"视图.我的代码如下:
function CalculateTransform(objectPath)
{
var results = '';
// Define bounds/points of viewport
var mapDimensions = getMapViewportDimensions();
var baseWidth = mapDimensions[0];
var baseHeight = mapDimensions[1];
var centerX = baseWidth / 2;
var centerY = baseHeight / 2;
// Get bounding box of object path and calculate centroid and zoom factor
// based on viewport.
var bbox = objectPath.getBBox();
var centroid = [bbox.x + bbox.width / 2, bbox.y + bbox.height / 2];
var zoomScaleFactor = baseHeight / …Run Code Online (Sandbox Code Playgroud) 我想在HTML5中制作一个梯形.我知道可以使用border radius和0的高度来完成:
#trapezoid {
border-bottom: 100px solid red;
border-left: 50px solid transparent;
border-right: 50px solid COLOR HERE;
height: 0;
width: 100px;
}
Run Code Online (Sandbox Code Playgroud)
但是,我想应用CSS3渐变,上面的方法只允许纯色.
以下样式将生成平行四边形.但有没有办法只偏斜一方,而不是两者?
-webkit-transform: skew(20deg);
Run Code Online (Sandbox Code Playgroud) 我正在使用CSS-Tricks中的代码来获取当前使用JavaScript的旋转变换(在CSS中).
JavaScript函数:
function getCurrentRotation( elid ) {
var el = document.getElementById(elid);
var st = window.getComputedStyle(el, null);
var tr = st.getPropertyValue("-webkit-transform") ||
st.getPropertyValue("-moz-transform") ||
st.getPropertyValue("-ms-transform") ||
st.getPropertyValue("-o-transform") ||
st.getPropertyValue("transform") ||
"fail...";
if( tr !== "none") {
console.log('Matrix: ' + tr);
var values = tr.split('(')[1];
values = values.split(')')[0];
values = values.split(',');
var a = values[0];
var b = values[1];
var c = values[2];
var d = values[3];
var scale = Math.sqrt(a*a + b*b);
// arc sin, convert from radians …Run Code Online (Sandbox Code Playgroud) 我正在创建一个使用CSS'变换比例属性的Web应用程序.如下图所示,我在一个容器内部有一个物体,它很好地贴合在里面,没有任何溢出的内容.这就是我希望的样子.

当我将对象重新缩放到大于容器的大小时,我的问题出现了.如图所示,显然对象大于容器.由"可滚动区域"的箭头和标签标记,容器可以滚动到这些区域,但标有"隐藏"的部分由于它们的溢出而不能通过滚动可见或访问.

为了实际查看我的问题,这里有一个使用我的代码链接到codepen:
我的CSS代码区域的片段如下:
#container {
position: fixed;
width: 300px;
height: 200px;
border: 1px solid #000000;
left: 0px;
top: 0px;
margin-left: 330px;
margin-top: 10px;
overflow: scroll;
display: block;
text-align: center;
}
#object {
position: relative;
width: 120px;
height: 120px;
display: inline-block;
background-color: rgba(255, 0, 255, 0.45);
margin-top: 40px;
border-radius: 25px;
transform: scale(3); /* This would be scale(1) on the small object */
}
Run Code Online (Sandbox Code Playgroud)
这个问题阻碍了我的网络应用程序的开发,所以提前感谢您的时间和贡献.
我没有在openCV中找到任何在java中将平面图像转换为圆柱形的示例,我希望它在2d而不是3d中渲染图像,也没有找到任何示例代码或书籍.下面是我想在杯子周围扭曲的图片的图像.
一本好书和示例代码将非常感激.
到目前为止我已经这样做了.建议我的@Amitay使图像凹陷,使用此示例将图像包裹在圆柱体周围但卡在转换上.
import java.io.File;
import org.bytedeco.javacpp.indexer.UByteBufferIndexer;
import org.bytedeco.javacpp.opencv_core.Mat;
import org.bytedeco.javacpp.opencv_core.*;
import static org.bytedeco.javacpp.opencv_highgui.imshow;
import static org.bytedeco.javacpp.opencv_highgui.waitKey;
import static org.bytedeco.javacpp.opencv_imgcodecs.CV_LOAD_IMAGE_COLOR;
import static org.bytedeco.javacpp.opencv_imgcodecs.imread;
/**
*
* @author BTACTC
*/
public class CupWrapping {
Mat image;
Mat dstImage;
int width;
int height;
public CupWrapping(File imageFile) {
image = imread(imageFile.getAbsolutePath(), CV_LOAD_IMAGE_COLOR);
width = image.size().width();
height = image.size().height();
dstImage = new Mat(width, height, image.type());
UByteBufferIndexer sI = image.createIndexer();
UByteBufferIndexer sD = dstImage.createIndexer();
for (int y = 0; …Run Code Online (Sandbox Code Playgroud)