- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是 DataFrame 的前 5 行(格式不佳,但您可以看到其中大部分值都可以转换为数字)
df.head()
ID Overall Acceleration Aggression Agility Balance Ball control Composure Crossing Curve Dribbling Finishing Free kick accuracy GK diving GK handling GK kicking GK positioning GK reflexes Heading accuracy Interceptions Jumping Long passing Long shots Marking Penalties Positioning Reactions Short passing Shot power Sliding tackle Sprint speed Stamina Standing tackle Strength Vision Volleys
0 20801 94 89 63 89 63 93 95 85 81 91 94 76 7 11 15 14 11 88 29 95 77 92 22 85 95 96 83 94 23 91 92 31 80 85 88
1 158023 93 92 48 90 95 95 96 77 89 97 95 90 6 11 15 14 8 71 22 68 87 88 13 74 93 95 88 85 26 87 73 28 59 90 85
2 190871 92 94 56 96 82 95 92 75 81 96 89 84 9 9 15 15 11 62 36 61 75 77 21 81 90 88 81 80 33 90 78 24 53 80 83
3 176580 92 88 78 86 60 91 83 77 86 86 94 84 27 25 31 33 37 77 41 69 64 86 30 85 92 93 83 87 38 77 89 45 80 84 88
4 167495 92 58 29 52 35 48 70 15 14 30 13 11 91 90 95 91 89 25 30 78 59 16 10 47 12 85 55 25 11 61 44 10 83 70 11
df.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 18085 entries, 0 to 18084
Data columns (total 36 columns):
ID 18085 non-null int64
Overall 18085 non-null int64
Acceleration 18085 non-null object
Aggression 18085 non-null object
Agility 18085 non-null object
Balance 18085 non-null object
Ball control 18085 non-null object
Composure 18085 non-null object
Crossing 18085 non-null object
Curve 18085 non-null object
Dribbling 18085 non-null object
Finishing 18085 non-null object
Free kick accuracy 18085 non-null object
...
dtypes: int64(2), object(34)
memory usage: 5.1+ MB
for column in full:
tmp = pd.Series(column)
column = tmp.astype("float64", errors="ignore")
df.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 18085 entries, 0 to 18084
Data columns (total 36 columns):
ID 18085 non-null int64
Overall 18085 non-null int64
Acceleration 18085 non-null object
Aggression 18085 non-null object
Agility 18085 non-null object
Balance 18085 non-null object
Ball control 18085 non-null object
Composure 18085 non-null object
Crossing 18085 non-null object
Curve 18085 non-null object
Dribbling 18085 non-null object
Finishing 18085 non-null object
Free kick accuracy 18085 non-null object
...
dtypes: int64(2), object(34)
memory usage: 5.1+ MB
最佳答案
将解决方案从评论迁移到答案。感谢@Wen。
df=df.apply(pd.to_numeric, errors='coerce')
关于Python - 使用 "astype"的 Pandas 列类型转换不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52240694/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!