问题标签 [data-munging]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - Why won't barchart in Pandas stack different values?
Using Pandas, python 3. Working in jupyter.
Ive made this graph below using the following code:
And then tried to do the same, but with divisions for Gender. I wanted to make this:
And made this monstrosity. I'm unfamiliar with pivot tables in pandas, and after reading documentation, am still confused. I'm assuming that aggfunc
affects the values given, but not the indices. How can I separate the loan status so that it reads as different colors for 'Y' and 'N'?
Trying a method similar to the methods used for temp3
simply yields a key error:
How can I make the 'Y' and 'N' appear separately as they are in the first graph, but for all 4 bars instead of using just 2 bars?
postgresql - “mode .insert”中sqlite的输出是否正确?
考虑我在 SQLite 数据库中创建的表,CREATE TABLE tbl(x);
其中包含以下数据:INSERT INTO tbl VALUES(1); INSERT INTO tbl VALUES(2);
. 现在,我希望创建一个我希望导入 PostgreSQL 的架构和数据的 SQL 文件,并执行以下操作:
输出是:
插入语句的输出不应该是INSERT INTO tbl VALUES(1); INSERT INTO tbl VALUES(2);
?
这不是一个真正的问题,因为我可以轻松地进行查找/替换来解决此问题,但这可能会引入无法预料的问题(例如更改插入语句中的数据)。
r - 将二进制结果的汇总表转换为 Long Tidy DataFrame
我想将具有多个分类变量的表以及二进制实验结果的摘要转换为长格式,以便轻松运行逻辑回归模型。
有没有一种简单的方法可以做到这一点,而不仅仅是制作一堆向量,rep()
然后将它们组合成一个dataframe
?理想情况下,我想要一个自动执行此操作的功能,但也许我只需要自己制作。
例如,如果我从这个汇总表开始:
我希望能够将其切换回以下格式:
谢谢!
python - rm() function of r alternative in python
How to remove the variables in python to clear ram memory in python?
R :
Python:
How to clear the single variables or a group of variables?
r - 使用 R 对数字进行四舍五入
我想以这种方式转换以下数字我尝试使用所有可能的方法但我无法获得我期望的值
上表供参考
r - 将一个表中 data.table 中的不同列值组合成另一个表的行值
我有下表 DT-1。列代表不同的状态
我想形成另一个表 DT-2,其中表中的行如下所述:
第 2 表的第 1-5 行由第 1 表的第 1 行构成。类似地,第 2 个表的第 6-10、11-12、13-14 和 15 行由表 1 的第 2、3、4、5 行构成。
是否有任何 data.table 方法或任何其他 R 包可以做到这一点?
python - Python pandas:在宽格式DataFrame中旋转某些变量
数据处理问题:如何有选择地从过宽的 DataFrame 中旋转某些变量?
例如,我想转:
进入:
请注意,x 被复制,y 与位置对齐。
直线pd.melt()
创建混合变量和数据类型,这些变量和数据类型不容易有选择地转回宽格式。
有什么建议吗?谢谢!
python - 将熊猫字符串列转换为日期时间,偶尔缺少小时部分
我将持续时间字符串记为“48m 37s”,有时记为“1h 38m 29s”,以及在熊猫数据框列中保存此数据的字符串集合
我正在尝试将持续时间列的数据类型转换为日期时间,如下所示
但失败并出现以下错误
我了解有时持续时间列的列表条目中缺少小时部分,并且想知道是否有一种方法可以指定多种格式,以防万一无法匹配其他格式。
这样做将产生如下输出,保留列中的条目顺序
python - Python/Pandas:按日期和 ID 对记录进行分组和计数
我在 Python 中有一个相对较大的数据框(~10^6 条记录),结构如下:
我正在尝试按日期(天)和 ID 分组,然后计算 1)每天和 ID 的记录总数,以及 2)每个“A”列(例如)中的“阳性”总数日期和 ID。最终,我想填充一个数据框,指示每天和 ID 的阳性数和记录总数,例如,
我最初使用了一个双 for 循环来遍历每个唯一的日期和 ID,但这花费了太多时间。我将不胜感激有关更好方法的帮助。提前感谢您的任何评论!