【问题标题】:Convert exponential number to discrete number将指数数转换为离散数
【发布时间】:2016-09-19 19:26:30
【问题描述】:

我有一个具有以下结构的熊猫数据框:

  Source    Code    DateTime    Actual
0    4      78     2016-09-18   6.618372e+01
1    4      124    2016-09-18   2.470248e+06
2    4      37     2016-09-16   1.260494e+01
3    4      5      2016-09-16   1.769238e+08
4    4      19     2016-09-16   1.000000e+00

我正在尝试使用 matplotlib 绘制实际值。但由于其中有指数值,我得到了一个错误。只是想知道有没有办法将此指数数转换为离散数。

任何帮助将不胜感激。

【问题讨论】:

  • 你能发布print(df.dtypes)的输出吗?
  • 源 int64,代码 int64,DateTime 对象,实际 float64
  • 它对我来说很好用:df.Actual.plot(figsize=(12,8))
  • 绘图时float 的值没有问题。它们不需要是整数。你的问题没有意义。错误是什么?

标签: pandas type-conversion


【解决方案1】:
In [91]: df.Actual.plot(figsize=(12,8))
Out[91]: <matplotlib.axes._subplots.AxesSubplot at 0x8f72390>

In [92]: df
Out[92]:
   Source  Code    DateTime        Actual
0       4    78  2016-09-18  6.618372e+01
1       4   124  2016-09-18  2.470248e+06
2       4    37  2016-09-16  1.260494e+01
3       4     5  2016-09-16  1.769238e+08
4       4    19  2016-09-16  1.000000e+00

In [93]: df.dtypes
Out[93]:
Source        int64
Code          int64
DateTime     object
Actual      float64
dtype: object

【讨论】:

  • 我使用谷歌图表(即每一天)来打印实际数据。我使用了 -- %%chart line --fields Source,Code,DateTime,Actual --data df1
  • @user3447653,我没听懂。你能解释一下你想画什么(x轴,y轴)吗?
猜你喜欢
  • 2011-10-24
  • 2021-02-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-07-26
  • 2012-03-01
  • 2021-01-04
相关资源
最近更新 更多