我和这里发布的问题有类似的问题:
Pandas DataFrame:从列中的字符串中删除不需要的部分
我需要从DataFrame中的字符串中删除换行符.基本上,我使用python的json模块访问了一个api,这一切都没问题.创建DataFrame也非常有效.但是,当我想最终将最终结果输出到csv时,我有点卡住了,因为有新行在csv文件中创建了错误的"新行".
所以基本上我试图改变这个:
'......这是一个段落.
这是另一段...'
进入这个:
'......这是一个段落.这是另一段...'
我不关心为段落中保留任何类型的'\n'或任何特殊符号.所以它可以被剥夺.
我尝试了一些变化:
misc['product_desc'] = misc['product_desc'].strip('\n')
AttributeError: 'Series' object has no attribute 'strip'
Run Code Online (Sandbox Code Playgroud)
这是另一个
misc['product_desc'] = misc['product_desc'].str.strip('\n')
TypeError: wrapper() takes exactly 1 argument (2 given)
misc['product_desc'] = misc['product_desc'].map(lambda x: x.strip('\n'))
misc['product_desc'] = misc['product_desc'].map(lambda x: x.strip('\n\t'))
Run Code Online (Sandbox Code Playgroud)
没有错误消息,但换行符也不会消失.同样的事情:
misc = misc.replace('\n', '')
Run Code Online (Sandbox Code Playgroud)
写入csv行是这样的:
misc_id.to_csv('C:\Users\jlalonde\Desktop\misc_w_id.csv', sep=' ', na_rep='', index=False, encoding='utf-8')
Run Code Online (Sandbox Code Playgroud)
熊猫的版本是0.9.1
谢谢!:)
仍然试图使Eclipse IDE工作并运行到不兼容的JVM错误.我按照这里的步骤操作:我安装了Java 7,但Eclipse一直说1.6不适合这个产品
但遗憾的是没有效果.运行OSX 10.9.5并卸载开箱即用的Mac版本.Java的新版本似乎出现在系统偏好设置中.请参阅随附的屏幕截图.我甚至做过一些基础知识,比如重新启动我的电脑等等.也许我需要对其他文件进行其他修改.我很熟悉终端,但对Eclipse和Java不熟悉.提前致谢!
在本地开发环境中使用Eclipse中的Forge 1.8.9(Mars.1版本(4.5.1)).
我试图在每次加入或重新加入世界时设置玩家的位置.它总是第一次工作(例如跑步和加入世界.见第一次屏幕截图).
在一点点移动世界之后,然后退出该世界并返回(同一会话中关闭MC),世界无法出现在控制台中.该位置与"全部正常"登录中的位置相同.另外还有一个错误的位置!错误.
控制台的错误在这里:
[05:47:53] [Server thread/INFO]: Player992 joined the game
[05:47:53] [Server thread/WARN]: Wrong location! (9, 9) should be (9, 6), EntityPlayerMP['Player992'/2371, l='world', x=145.00, y=73.00, z=145.00]
[05:48:18] [Server thread/INFO]: Saving and pausing game...
[05:48:18] [Server thread/INFO]: Saving chunks for level 'world'/Overworld
[05:48:18] [Server thread/INFO]: Saving chunks for level 'world'/Nether
[05:48:18] [Server thread/INFO]: Saving chunks for level 'world'/The End
Run Code Online (Sandbox Code Playgroud)
我尝试了一些这方面的变体,包括Minecraft Forge:为setLocationAndAngles使用正确的Join Game侦听器但没有骰子(不同的行为).
忽略所有不相关的"进口".它们是我多次尝试的文物.
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; …Run Code Online (Sandbox Code Playgroud)