python - 将整列中的时间转换为字符串
问题描述
我想将整个列中的时间更改为字符串。请举例说明方法。下面给出的是我的数据。
timeseries CCN Number Conc SS
0 00:00:00 15.810967 0.1
1 00:05:00 358.401000 0.3
2 00:10:00 797.538333 0.5
下面给出的是我的代码:
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
load_file=pd.read_excel(r'E:\CCNC\CCNCCodes\Modulated output\Copy of Final_modulated_ccnc_data.xlsx',header=0)
load_file.columns
s=load_file.loc[0:289,['Timeseries',' CCN Number Conc','SS']]
谢谢你。
解决方案
只需告诉 Pandas 将您想要的列加载为字符串:
pd.read_excel(filename, dtype={'Timeseries': str}, header=0)
这样您就不必在以后转换它们,这会浪费时间。
推荐阅读
- c - 在C中生成随机矩阵但数字位置相同
- aws-lambda - AWS Cognito - 未触发自定义质询
- postgresql - 数组的所有条目的 Postgres JSONB 日期条件为真
- node.js - 数据库中的相同日期从后端到前端使用不同的 UTC 偏移量
- mysql - 无法在 Mysql 中插入数据
- ruby-on-rails - 如何从 Rails 关联中的控制器访问数据
- xamarin - 如何在 CollectionView / Xamarin 中居中图片列表
- javascript - TypeError:无法读取未定义的属性“状态”。但是状态可以成功 console.logged (REACT)
- linux - 如何在领域中将密码作为参数提供给活动目录命令
- java - 如何比较两个哈希图以查看键是否相等?