重塑数据帧(使用R

2024-09-27 19:28:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道是否有可能得到这样的结果:

例如:

exemple

使用此数据帧

df
      y Faisceaux destination Trajet RED_Groupe Nbr observation RED       Pond Nbr observation total       RED        pct
1  2015        France DOM-TOM  Aller   78248.47                  87   85586.75                   307 0.9142591 0.04187815
2  2015         Hors Schengen  Aller  256817.64                 234  195561.26                  1194 1.3132337 0.06015340
3  2015         INTERNATIONAL  Aller  258534.78                 473  288856.53                  2065 0.8950283 0.04099727
4  2015               Maghreb  Aller  605514.45                 270  171718.14                  1130 3.5262113 0.16152007
5  2015              NATIONAL  Aller  361185.82                 923 1082529.19                  5541 0.3336500 0.01528302
6  2015              Schengen  Aller  312271.06                 940  505181.07                  4190 0.6181369 0.02831411
7  2015        France DOM-TOM Retour   30408.70                  23   29024.60                   108 1.0476871 0.04798989
8  2015         Hors Schengen Retour  349805.15                 225  168429.96                   953 2.0768583 0.09513165
9  2015         INTERNATIONAL Retour  193536.63                 138   99160.52                   678 1.9517509 0.08940104
10 2015               Maghreb Retour  302863.83                 110   41677.90                   294 7.2667735 0.33285861
11 2015              NATIONAL Retour  471520.80                 647  757258.33                  3956 0.6226684 0.02852167
12 2015              Schengen Retour  307691.66                 422  243204.76                  2104 1.2651548 0.05795112

不使用Exel。 用R还是Python?我不知道这样拆分列是否可行。你知道吗


Tags: 数据dfreddomobservationtomnbrnational
1条回答
网友
1楼 · 发布于 2024-09-27 19:28:47

感谢这里的所有评论,我的解决方案是:

我将数据帧分为两个数据帧df15(2015年数据)和df16(2016年数据),然后:

mytable15 <- tabular(Heading()*Faisceaux_destination ~ Trajet*(`RED_Groupe` + `Nbr observation RED` + Pond + `Nbr observation total` + RED + pct)*Heading()*(identity),data=df15)
mytable16 <- tabular(Heading()*Faisceaux_destination ~ Trajet*(`RED_Groupe` + `Nbr observation RED` + Pond + `Nbr observation total` + RED + pct)*Heading()*(identity),data=df16)

相关问题 更多 >

    热门问题