【发布时间】:2021-08-31 05:49:08
【问题描述】:
我有这样的输入如下。它是一个字符串列表,每个奇数字符串都是一个以 MR 开头的数字,每个偶数字符串都是一些混合文本。我需要将此字符串列表转换为严格包含两列的 pandas 数据框,但由于某些 MR 数字与不同的混合文本计数器部分配对多次出现,因此在重复 MR 的地方我都会得到额外的列,正如我在下面演示的那样:
list = ['MR4044696:',
'The GAP Group, GAP – groups, algorithms and programming, version 4.10, Available from http://www.gap-system.org, 2018.',
'MR2900886:',
'The GAP Group, $GAP$ groups, algorithms, and programming, version 4.4.12 (2008), http://www.gap-system.org.',
'MR3169623:',
'Distler, A., Mitchell, J. D. (2011). Smallsemi - A Library of Small Semigroups. Oct A GAP 4 package [5], Version 0.6.4.',
'MR3169623:',
'The GAP Group, (2008). (http://www.gap-system.org). GAP–Groups, Algorithms, and Programming, Version 4.4.12.',
'MR4180136:',
'The GAP Group, 2019. GAP – Groups, Algorithms, and Programming, Version 4.10.1; https://www.gap-system.org.',
'MR11:',
'GAP group',
'MR1111111:',
'Distler, A., Mitchell, J. D. (2011). Smallsemi - A Library of Small Semigroups. Oct A GAP 4 package [5], Version 0.6.4.',
'MR1111111:',
'The GAP Group, (2008). (http://www.gap-system.org). GAP–Groups, Algorithms, and Programming, Version 4.4.12.',
'MR5:',
'V. A. Artamonov and A. A. Bovdi, Integral gro GAP up rings: Groups of invertible elements and classical $K$-theory, in Algebra, Topology, Geometry, Vol. 27 (Russian), Itogi Nauki i Tekhniki, 232. (Vsesoyuz. Inst. Nauchn. i Tekhn. Inform., Moscow, 1989), pp. 3–43. \nMR1039822',
'MR5:',
"V. Bovdi, A. Grishkov and A. Konovalov, Kimmerle @GAP a lapa conjecture for the Held and O'Nan sporadic simple groups, Sci. Math. Jpn. 69(3) (2009) 353–361. \nMR2510100",
'MR5:',
'V. Bovdi and A. Konovalov, Integral group ringaper GAP? eg of the McLaughlin simple group, Algebra Discrete Math. 2 (2007) 43–53. \nMR2364062',
'MR7:',
'V. A. Artamonov and A. A. Bovdi, Integral gro GAP up rings: Groups of invertible elements and classical $K$-theory, in Algebra, Topology, Geometry, Vol. 27 (Russian), Itogi Nauki i Tekhniki, 232. (Vsesoyuz. Inst. Nauchn. i Tekhn. Inform., Moscow, 1989), pp. 3–43. \nMR1039822',
'MR7:',
"V. Bovdi, A. Grishkov and A. Konovalov, Kimmerle @GAP a lapa conjecture for the Held and O'Nan sporadic simple groups, Sci. Math. Jpn. 69(3) (2009) 353–361. \nMR2510100",
'MR7:',
'V. Bovdi, E. Jespers and A. Konovalov, Tors gap ion gap GAP gappen units in integral group rings of Janko sgapimple groups, Math. Comp. 80 (2011) 593–615. \nMR2728996',
'MR7:',
'V. Bovdi and A. Konovalov, Integral group ringaper GAP? eg of the McLaughlin simple group, Algebra Discrete Math. 2 (2007) 43–53. \nMR2364062',
'MR9:',
'The GAP Group, $GAP$ groups, algorithms, and programming, version 4.4.12 (2008), http://www.gap-system.org.']
我需要转换为 pandas df,其中一列用于 MR 编号,另一列用于其余部分。
我试过 df = pd.DataFrame(list) ,但因为一些 MR 数字重复,我得到了额外的列。我知道这可能是一个愚蠢的问题,但我无法解决,谢谢。
我只需要两列,如果有重复的 MR 编号,我需要它在单独的行中,例如:
MR Rest
111 'asd'
222 'fgh'
333 'fff'
333 'ghj'
444 'yyy'
555 'hjk'
555 'jkl'
【问题讨论】: