小编Sup*_*ohn的帖子

如何从镶木地板文件中获取架构/列名称?

我有一个存储在HDFS中的文件 part-m-00000.gz.parquet

我试图运行,hdfs dfs -text dir/part-m-00000.gz.parquet但它已经压缩,所以我运行gunzip part-m-00000.gz.parquet但它没有解压缩文件,因为它无法识别.parquet扩展名.

如何获取此文件的架构/列名称?

hadoop apache-pig hdfs parquet

22
推荐指数
4
解决办法
4万
查看次数

ImportError:没有名为'email.mime'的模块; 电子邮件不是一个包

运行以下代码时,我不断收到错误:

ImportError: No module named 'email.mime'; email is not a package
Run Code Online (Sandbox Code Playgroud)

所以我跑:

pip install email
Run Code Online (Sandbox Code Playgroud)

并得到以下错误:

ImportError: No module named 'cStringIO'...
Command "python setup.py egg_info" failed with error code 1
Run Code Online (Sandbox Code Playgroud)

互联网告诉我运行:

pip install --upgrade pip
Run Code Online (Sandbox Code Playgroud)

要解决这个问题,我现在做了很多次.我不知道还能做些什么.

Python版本:Python 3.3.5 | Anaconda 2.3.0(x86_64)

import smtplib,email,email.encoders,email.mime.text,email.mime.base

smtpserver = 'email@site.com'
to = ['address@gmail.com']
fromAddr = 'email@site.com'
subject = "testing email attachments"

# create html email
html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '
html +='"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">'
html +='<body style="font-size:12px;font-family:Verdana"><p>...</p>'
html += "</body></html>" …
Run Code Online (Sandbox Code Playgroud)

python pip

18
推荐指数
3
解决办法
4万
查看次数

R - 在 R 中使用 VPN 连接到 MySQL

I want to run an R script on a remote server that depends on a MySQL connection that requires VPN. I do this on my local machine using a Cisco VPN client.

Is there any way to facilitate a MySQL connection for an R application where VPN is required?

More specifically, I'm interested in facilitating either a knitr script to produce html on the remote server or to deploy my shiny app on the remote server, but for both I …

mysql vpn r

5
推荐指数
1
解决办法
2447
查看次数

在 R 或 MySQL 中创建一个交叉频率表

我有一个 user_id - 类别对表。用户可以分为多个类别。我正在尝试为每个可能的结果获得跨类别的计数。即属于 A 类和 C 类的用户数量等。

我的原始数据结构如下:

示例结果

我想要看起来像这样的结果,显示跨类别的计数:

示例结果

这如何在 R 或 MySQL 中完成?数据相当大。

以下是示例数据:

data <- structure(list(category = structure(c(1L, 2L, 2L, 1L, 3L, 3L, 
2L, 1L, 3L, 2L, 2L, 2L, 3L, 1L, 1L, 3L), .Label = c("A", "B", 
"C"), class = "factor"), user_id = c(464L, 345L, 342L, 312L, 
345L, 234L, 423L, 464L, 756L, 756L, 345L, 345L, 464L, 345L, 234L, 
312L)), .Names = c("category", "user_id"), class = "data.frame", row.names = c(NA, 
-16L))
Run Code Online (Sandbox Code Playgroud)

任何代码片段,对方法、功能或包建议的想法都将不胜感激。谢谢!-约翰

mysql r

5
推荐指数
1
解决办法
261
查看次数

根据前导空格的数量将列分隔为新列

这些报告来自quickbooks,下载为Excel文件.请注意,左列是基于左侧间距的嵌套层次结构.

我需要根据左侧前导空格的数量将Description列分隔为单独的列.

由于我最近一直在处理财务报告,因此这些报告非常普遍,而且非常难以使用.是否有用于导入此类数据的包或函数?

在此输入图像描述

以下是可重现的输入数据框示例:

df1 <- structure(list(Description = c("asset", " current asset", "   bank acc", 
                                      "    banner", "    clearing",
                                      "   total bank accounts",
                                      " total current assets"),
                 Total = c(NA, NA, NA, 10L, 20L, 30L, 30L)),
            .Names = c("Description", "Total"), 
            class = "data.frame", 
            row.names = c(NA, -7L))
Run Code Online (Sandbox Code Playgroud)

excel whitespace quickbooks r indentation

4
推荐指数
1
解决办法
182
查看次数

按列分组的数据帧上 R 中的行之间的差异

我希望通过 app_name 获得不同版本的计数差异。我的数据集如下所示:app_name、version_id、count、[difference]

这是数据集

    data = structure(list(app_name = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 
2L, 3L, 3L), .Label = c("a", "b", "c"), class = "factor"), version_id = c(1, 
1.1, 2.3, 2, 3.1, 3.3, 4, 1.1, 2.4), count = c(600L, 620L, 620L, 
200L, 200L, 250L, 250L, 15L, 36L)), .Names = c("app_name", "version_id", 
"count"), class = "data.frame", row.names = c(NA, -9L))
Run Code Online (Sandbox Code Playgroud)

给定这个 data.frame,我如何获得 app_name 和 version_id 的计数滞后差异?每个应用程序的初始(第一个)版本差异将为零,因为没有差异。

以下是最终“差异”列的最终结果的示例

structure(list(app_name = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 
2L, 3L, 3L), .Label = c("a", …
Run Code Online (Sandbox Code Playgroud)

diff r lag dataframe

3
推荐指数
1
解决办法
1888
查看次数

在python中爆炸多个csv字段

我有一个200行的excel文件,其中2行有逗号分隔值.如果我将它们输出到制表符分隔符,它将如下所示:

col1  col2    col3
a     b,c     d,e
f     g,h     i,j
Run Code Online (Sandbox Code Playgroud)

我需要爆炸才能获得这样的数据帧,将200行扩展到~4,000:

col1  col2  col3
a     b     d
a     b     e
a     c     d
a     c     e
f     g     i
f     g     j
f     h     i
f     h     j
Run Code Online (Sandbox Code Playgroud)

我没有在pandas中看到任何爆炸功能,并且无法弄清楚如何使逗号分隔值的列长度不均匀 - 不确定分割在这里如何工作.

帮助我堆叠溢出,你是我唯一的希望.谢谢!

python pandas

2
推荐指数
1
解决办法
95
查看次数

无法在Linux Server上安装任何R软件包

我似乎无法在我的amazon linux服务器上安装任何R软件包,在EC2上运行.这是一个尝试安装"扫帚"包的简单示例.知道这里发生了什么吗?任何帮助将不胜感激,因为我已经坚持了约5个小时.我已经粘贴了下面的所有控制台输出.

install.packages( "扫帚")

Installing package into ‘/home/rstudio/R/x86_64-redhat-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependencies ‘mnormt’, ‘psych’

trying URL 'https://cran.rstudio.com/src/contrib/mnormt_1.5-5.tar.gz'
Content type 'application/x-gzip' length 37169 bytes (36 KB)
==================================================
downloaded 36 KB

trying URL 'https://cran.rstudio.com/src/contrib/psych_1.7.8.tar.gz'
Content type 'application/x-gzip' length 3311758 bytes (3.2 MB)
==================================================
downloaded 3.2 MB

trying URL 'https://cran.rstudio.com/src/contrib/broom_0.4.3.tar.gz'
Content type 'application/x-gzip' length 1397648 bytes (1.3 MB)
==================================================
downloaded 1.3 MB

* installing *source* package ‘mnormt’ ...
** package ‘mnormt’ successfully unpacked and MD5 sums checked
** libs …
Run Code Online (Sandbox Code Playgroud)

linux r rstudio-server

1
推荐指数
1
解决办法
592
查看次数