回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我将python列表转换为Pandas数据帧,然后将数据帧写入csv。清单如下:</p>
<pre><code>name = ['james beard', 'james beard']
ids = [304589, 304589]
year = [1999, 1999]
co_authors = [['athman bouguettaya', 'boualem benatallah', 'lily hendra', 'kevin smith', 'mourad quzzani'], ['athman bouguettaya', 'boualem benatallah', 'lily hendra', 'kevin smith', 'mourad quzzani']]
title = ['world wide databaseintegrating the web corba and databases', 'world wide databaseintegrating the web corba and databases']
venue = ['international conference on management of data', 'international conference on management of data']
data = {
'Name': name,
'ID': ids,
'Year': year,
'Co-author': co_authors,
'Title:': title,
'Venue:': venue,
}
df = pd.DataFrame(data, columns=['Name','ID','Year','Co-author','Title', 'Venue'])
df
df.to_csv('test.csv')
</code></pre>
<p>我的问题是</p>
<p>(a)“标题”和“地点”列显示为“NaN”,而不是它们的值(见下文)。我该怎么解决这个问题?在</p>
^{pr2}$
<p>(b)在CSV(见下文)中,如何在标题中添加“Index”并删除“Co-author”中的括号?在</p>
<pre><code>,Name,ID,Year,Co-author,Title,Venue
0,james beard,304589,1999,"['athman bouguettaya', 'boualem benatallah', 'lily hendra', 'kevin smith', 'mourad quzzani']",,
1,james beard,304589,1999,"['athman bouguettaya', 'boualem benatallah', 'lily hendra', 'kevin smith', 'mourad quzzani']",,
</code></pre>