小编tro*_*tor的帖子

使用Seaborn FacetGrid从数据框中绘制错误条

我想在Seaborn FacetGrid上的pandas数据框中的列中绘制误差条

import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar']*2,
                   'B' : ['one', 'one', 'two', 'three',
                         'two', 'two', 'one', 'three'],
                  'C' : np.random.randn(8),
                  'D' : np.random.randn(8)})
df
Run Code Online (Sandbox Code Playgroud)

示例数据帧

    A       B        C           D
0   foo     one      0.445827   -0.311863
1   bar     one      0.862154   -0.229065
2   foo     two      0.290981   -0.835301
3   bar     three    0.995732    0.356807
4   foo     two      0.029311    0.631812
5   bar     two      0.023164   -0.468248
6   foo     one     -1.568248    2.508461
7 …
Run Code Online (Sandbox Code Playgroud)

python plot matplotlib pandas seaborn

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

如何将时间戳列转换为纪元秒?

如何将时间戳列转换为纪元秒?

var df = sc.parallelize(Seq("2018-07-01T00:00:00Z")).toDF("date_string")
df = df.withColumn("timestamp", $"date_string".cast("timestamp"))
df.show(false)
Run Code Online (Sandbox Code Playgroud)

数据框:

+--------------------+---------------------+
|date_string         |timestamp            |
+--------------------+---------------------+
|2018-07-01T00:00:00Z|2018-07-01 00:00:00.0|
+--------------------+---------------------+
Run Code Online (Sandbox Code Playgroud)

timestamp scala apache-spark apache-spark-sql

3
推荐指数
2
解决办法
8217
查看次数