使用熊猫数据框后无法将字符串转换为浮点型

时间:2019-03-19 19:21:55

标签: python python-3.x pandas csv dataframe

我有一个代码,我将在其中放置3D图像目录并将所有图像转换为单个行数组并保存在单个csv中。我有45个图片目录:

filenames = glob("C:\\Users\\rzara\\Desktop\\resized\\arrays\\*.csv")
dataframes = [pd.read_csv(f, header = None) for f in filenames]
pd.DataFrame(dataframes).to_csv("C:\\Users\\rzara\\Desktop\\resized\\arrays\\Combined.csv", header = None)

我可以通过无监督学习网络运行这些单独的.csv文件。但是,我想将所有45个.csv文件合并为1个.csv文件,以相互比较3D体积。我有这段代码可以合并所有.csv:

ValueError: could not convert string to float: '  52.0  38.0  31.0 ... 27.0  27.0  27.0\n\n[20 rows x 2500 columns]'

当我尝试运行代码时使用pandas数据框合并文件后,出现错误:

ValueError: could not convert string to float: '...'

我尝试手动编辑.csv并删除所有多余的字符,空格和返回,但随后出现错误:

html {
  font-size: 18px;
}
@media (min-width: 576px) {
  .container {
    max-width: 540px;
 }
}
@media (min-width: 768px) {
  .container {
    max-width: 720px;
 }
}
@media (min-width: 992px) {
  .container {
    max-width: 960px;
 }
}
@media (min-width: 1200px) {
  .container {
    max-width: 1400px;
 }
}
h1, .h1 {
  font-size: 3.815rem;
}
h2, .h2 {
  font-size: 2.441rem;
}
h3, .h3 {
  font-size: 1.563rem;
}
h4, .h4 {
  font-size: 1.25rem;
}
.project-methodology-wrap {
  padding: 5rem 0;
 /*========== Media queries ==========*/
}
.project-methodology-wrap .methodologyBullet::before {
  content: '';
  width: 25px;
  height: 25px;
  background: #d4272e;
  position: absolute;
  border-radius: 30px;
  left: 26px;
  top: 0px;
  opacity: 0;
}
.project-methodology-wrap .methodologyBullet::after {
  content: '';
  width: 12px;
  height: 12px;
  background: #d4272e;
  position: absolute;
  border-radius: 30px;
  left: 33px;
  top: 2px;
}
.project-methodology-wrap .project-methodology-list.active .methodologyBullet {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.project-methodology-wrap .project-methodology-list.active .methodologyBullet::before {
  opacity: 1;
  transition-duration: 0.5s;
  left: 26px;
}
.project-methodology-wrap .project-methodology-list.active .methodologyBullet::after {
  border: 5px solid #fff;
  width: 21px;
  height: 21px;
  left: 28px;
}
.project-methodology-wrap .project-methodology-listCount, .project-methodology-wrap .methodologyBullet {
  position: absolute;
  left: 0;
}
.project-methodology-wrap .project-methodology-leftContent {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
}
.project-methodology-wrap .project-methodology-rightContent {
  position: relative;
  overflow: hidden;
}
.project-methodology-wrap .project-methodology-rightContent:before {
  content: "";
  height: 100%;
  width: 8px;
  position: absolute;
  background-color: #f1f2f6;
  left: calc((100% - 3 * 5rem) * .54 - -2px)!important
}
.project-methodology-wrap .project-methodology-rightContent .project-methodology-list {
  position: relative;
  -webkit-perspective: 1000px;
  perspective: 1000px;
  padding-left: 80px;
  margin-bottom: 3rem;
}
.project-methodology-wrap .project-methodology-rightContent .project-methodology-list .project-methodology-listContent {
  opacity: 0.2;
  transition-duration: 0.4s;
  -webkit-transform: none;
  transform: none;
}
.project-methodology-wrap .project-methodology-rightContent .project-methodology-list.active .project-methodology-listContent {
  opacity: 1;
}

}

0 个答案:

没有答案