pyspark - 从 HDFS 和 Schema 问题读取 Parquet
问题描述
当我尝试从 HDFS 读取镶木地板文件时,我得到了所有混合大小写的模式。有什么办法可以将其转换为全部小写?
df=spark.read.parquet(hdfs_location)
df.printSchema();
root
|-- RecordType: string (nullable = true)
|-- InvestmtAccnt: string (nullable = true)
|-- InvestmentAccntId: string (nullable = true)
|-- FinanceSummaryID: string (nullable = true)
|-- BusinDate: string (nullable = true)
What i need is like below
root
|-- recordtype: string (nullable = true)
|-- investmtaccnt: string (nullable = true)
|-- investmentaccntid: string (nullable = true)
|-- financesummaryid: string (nullable = true)
|-- busindate: string (nullable = true)
解决方案
首先阅读镶木地板文件
df=spark.read.parquet(hdfs_location)
然后使用.toDF
函数创建所有数据框lower column names
df=df.toDF(*[c.lower() for c in df.columns])
推荐阅读
- ruby - 如何解码 Google::Apis::AdminDirectoryV1::UserPhoto.photo_data
- javascript - Reactstrap 模态在按钮单击时全部打开
- java - 从 CSV 文件读取后,将循环内的特定任务设为多线程
- apache-kafka - 我可以从 Lambda 函数写入 AWS MSK Kafka 集群吗?
- assembly - 计算一个字节中零和一的数量
- vba - 从新电子邮件中保存附件
- multithreading - 如何访问作为参数传递给python中另一个类的类的方法
- performance - IIS/DMZ - 网站慢
- python - 使用 Python Beautifulsoup 从 LinkedIn 收集数据
- php - 当表中不存在值时出现插入重复键错误-SQL Server