简体   繁体   English

Pandas Read csv 只读取一行

[英]Pandas Read csv just read a line of a row

I have a classic panda data frame made of ID and Text.我有一个由 ID 和文本组成的经典熊猫数据框。 I would like to get just one column and therefore i use the typical df["columnname"] .我只想得到一列,因此我使用典型的df["columnname"] But at this point it becomes a Pandas Series.但此时它变成了熊猫系列。 Is there a way to make a new dataframe with just that single column?有没有办法只用那一列制作一个新的数据框? I'm asking this is because if I cast the Pandas series in a string ( columnname = columnname.astype ("string") ) and I save it in a text file, I see that it only saves the first sentence of each line and not the entire textual content, as I would like.我问这是因为如果我将 Pandas 系列转换为字符串( columnname = columnname.astype ("string") )并将其保存在文本文件中,我会看到它只保存每行的第一句并且不是我想要的整个文本内容。

If there are any other solution, I'm open to learn :)如果还有其他解决方案,我愿意学习:)

试试这个: pd.DataFrame(dfname["columnname"])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM