如何将RDD(org.apache.spark.rdd.RDD[org.apache.spark.sql.Row])转换为Dataframe org.apache.spark.sql.DataFrame.我使用了将数据帧转换为rdd .rdd.处理完之后我想把它放回到数据帧中.我怎样才能做到这一点 ?
如何在连接两个数据帧时提供更多列条件.例如,我想运行以下内容:
val Lead_all = Leads.join(Utm_Master,
Leaddetails.columns("LeadSource","Utm_Source","Utm_Medium","Utm_Campaign") ==
Utm_Master.columns("LeadSource","Utm_Source","Utm_Medium","Utm_Campaign"),
"left")
Run Code Online (Sandbox Code Playgroud)
我想只在这些列匹配时才加入.但是上面的语法无效,因为cols只需要一个字符串.那我怎么得到我想要的东西.
我有一个CSV,其中一个字段是特定格式的日期时间.我无法直接在我的Dataframe中导入它,因为它需要是一个时间戳.所以我将它作为字符串导入并将其转换为Timestamp这样的
import java.sql.Timestamp
import java.text.SimpleDateFormat
import java.util.Date
import org.apache.spark.sql.Row
def getTimestamp(x:Any) : Timestamp = {
val format = new SimpleDateFormat("MM/dd/yyyy' 'HH:mm:ss")
if (x.toString() == "")
return null
else {
val d = format.parse(x.toString());
val t = new Timestamp(d.getTime());
return t
}
}
def convert(row : Row) : Row = {
val d1 = getTimestamp(row(3))
return Row(row(0),row(1),row(2),d1)
}
Run Code Online (Sandbox Code Playgroud)
使用Dataframe API或spark-sql有更好,更简洁的方法吗?上述方法需要创建RDD并再次为Dataframe提供架构.
如何阻止这些消息进入我的spark-shell控制台.
5 May, 2015 5:14:30 PM INFO: parquet.hadoop.InternalParquetRecordReader: at row 0. reading next block
5 May, 2015 5:14:30 PM INFO: parquet.hadoop.InternalParquetRecordReader: RecordReader initialized will read a total of 89213 records.
5 May, 2015 5:14:30 PM INFO: parquet.hadoop.InternalParquetRecordReader: block read in memory in 2 ms. row count = 120141
5 May, 2015 5:14:30 PM INFO: parquet.hadoop.InternalParquetRecordReader: at row 0. reading next block
5 May, 2015 5:14:30 PM INFO: parquet.hadoop.InternalParquetRecordReader: block read in memory in 2 ms. row count = 89213
5 …Run Code Online (Sandbox Code Playgroud) 我在我的一个AngularJS应用程序中使用Slick轮播.为此,我创建了如下指令:
myApp.directive('slickSlider',function(){
return {
restrict: 'A',
link: function(scope,element,attrs) {
$(element).slick(scope.$eval(attrs.slickSlider));
}
}
});
Run Code Online (Sandbox Code Playgroud)
这是我在视图文件中的代码:
<div class="clearfix"
slick-slider="{dots: false, arrows: true, draggable:
false, slidesToShow:3, infinite:false}">
<div class="my-slide">
<a><img ng-src="assets/img/img1.png"/></a>
</div>
<div class="my-slide">
<a><img ng-src="assets/img/img1.png"/></a>
</div>
<div class="my-slide">
<a><img ng-src="assets/img/img1.png"/></a>
</div>
<div class="my-slide">
<a><img ng-src="assets/img/img1.png"/></a>
</div>
<div class="my-slide">
<a><img ng-src="assets/img/img1.png"/></a>
</div>
<div class="my-slide">
<a><img ng-src="assets/img/img1.png"/></a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,它工作正常并正确初始化.
但是当我使用ngRepeat动态创建幻灯片时,它没有初始化并一个接一个地显示幻灯片.
这是我使用ngRepeat的代码
<div class="clearfix"
slick-slider="{dots: false, arrows: true, draggable:
false, slidesToShow:3, infinite:false}">
<div class="my-slide" ng-repeat="slide in …Run Code Online (Sandbox Code Playgroud) 我在我的页面上使用光滑的轮播http://kenwheeler.github.io/slick/,现在我需要在其中添加带自动播放的视频.
我使用这段代码
HTML
<div class="main-slider" id="main-slider">
<div>
<div class="video-wrapper">
<video autoplay loop class="pageBackground-video">
<source src="/Content/video/332145276.mp4" type="video/mp4">
</video>
</div>
</div>
<div>
<div class="video-wrapper">
<video autoplay loop class="pageBackground-video">
<source src="/Content/video/332145276.mp4" type="video/mp4">
</video>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
和脚本
$('#main-slider').slick({
slidesToShow: 1,
slidesToScroll: 1,
autoplay: true,
autoplaySpeed: 30000,
dots: true,
infinite: true,
adaptiveHeight: true,
arrows: false
});
Run Code Online (Sandbox Code Playgroud)
但是自动播放不起作用.有没有办法让自动播放工作?
我尝试使用upd
$('#main-slider').on('afterChange', function(event, slick, currentSlide, nextSlide){
var video = currentSlide.children('video').get(0).play();
});
Run Code Online (Sandbox Code Playgroud)
但我得到一个错误,Uncaught TypeError: currentSlide.children is not a function因为currentSlide它只是一个数字(0,1等).如何获得当前元素?
upd2我使用这个代码,它的工作原理 …
我一直在玩Slick旋转木马几个小时,真的无法理解如何实现Slick网站上的"中心模式":http://kenwheeler.github.io/slick/
它看起来像这样:

我已经有了当前的代码,但它仍然没有给我我想要的东西:
< link rel = "stylesheet"
type = "text/css"
href = "http://cdn.jsdelivr.net/jquery.slick/1.3.15/slick.css" >
< script type = "text/javascript"
src = "http://code.jquery.com/jquery-1.11.0.min.js" > < /script>
<link rel="stylesheet" type="text/css
" href="
http: //kenwheeler.github.io/slick/css/style.css">
< script type = "text/javascript"
src = "http://cdn.jsdelivr.net/jquery.slick/1.3.15/slick.min.js" > < /script>
<script type="text/javascript
">
$(document).ready(function() {
$('.center').slick({
centerMode: true,
centerPadding: '60px',
slidesToShow: 3,
responsive: [
{
breakpoint: 768,
settings: {
arrows: false,
centerMode: true,
centerPadding: '40px',
slidesToShow: 3
}
},
{
breakpoint: 480,
settings: …Run Code Online (Sandbox Code Playgroud)Slick Carousel:http://kenwheeler.github.io/slick/
如何在事件中获取幻灯片的元素?例如:
.on('afterChange', function (slick, currentSlide)
{
var currentSlideElement = //Get current slide element here
});
Run Code Online (Sandbox Code Playgroud)
第一个参数似乎是event对象,但它的target(或currentTarget)始终是幻灯片容器,第二个参数似乎是光滑的对象....
我按照以下链接的示例进行了操作:https://github.com/hakimel/reveal.js#multiplexing,但不知何故多路复用不起作用 - 当主幻灯片更新时客户端不会更新.我已经尝试使用reveal.js demo socket.io服务器,并尝试托管我自己的.
这两个选项都不起作用,我很确定我已经正确配置它们.这是我的配置代码:
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
multiplex: {
id: 'e2bc6e79f19fbe63',
secret: '13661966883862075064',
url: 'revealjs.jit.su:80'
},
dependencies: [
{ src: '//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.10/socket.io.min.js', async: true },
{ src: 'plugin/multiplex/client.js', async: true },
{ src: 'plugin/multiplex/master.js', async: true },
]
// { src: 'plugin/search/search.js', async: true, condition: function() { return !!document.body.classList; } }
// { src: 'plugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } }
});
Run Code Online (Sandbox Code Playgroud)
我无法将当前和总数量的幻灯片显示在slick.js幻灯片下方.谢谢你的帮助!!
$('.recipeThumbs').slick({
dots: true,
arrows: true,
slidesToShow: 4,
slidesToScroll: 4,
infinite: true,
responsive: [
{
breakpoint: 768,
settings: {
dots: false,
arrows: true,
centerMode: true,
centerPadding: '40px',
slidesToShow: 2,
slidesToScroll: 1
}
},
{
breakpoint: 480,
settings: {
dots: false,
arrows: true,
centerMode: true,
centerPadding: '40px',
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
Run Code Online (Sandbox Code Playgroud)