摘要:使用hive时,建立数据库,建表,写数据; 读数据:select * from test_t2; 报错SemanticException 原因:建表时使用了其他路径,或者在另一个路径的数据库(建立数据库时指定了location参数:create database words_db location
阅读全文
摘要:#_*_coding:utf-8_*_ # spark读取csv文件 #指定schema: schema = StructType([ # true代表不为null StructField("column_1", StringType(), True), # nullable=True, this
阅读全文
摘要:1. schema参数,AssertionError: dataType should be DataType # AssertionError: dataType should be DataType schema = StructType([ # true代表不为空 StructField("c
阅读全文
摘要:1. pyspark读csv文件后无法显示中文 #pyspark读取csv格式时,不能显示中文 df = spark.read.csv(r"hdfs://mymaster:8020/user/root/data_spark.csv", schema=schema) #解决方法,加入encoding=
阅读全文
摘要:Mysql错误 [Err] 1630 1. 错误 1630 [SQL]select date_format(now (),'%Y%m%d'); [Err] 1630 - FUNCTION db.now does not exist. Check the 'Function Name Parsing
阅读全文
摘要:Python使用中可能遇到的小问题 AttributeError: 'NoneType' object has no attribute 'extend' 或者AttributeError: 'NoneType' object has no attribute 'append' 原因:这两种方法都是
阅读全文
摘要:官网:https://packaging.python.org/tutorials/installing-packages/ 首先查看已安装的包: 1. 命令行模式输入:pydoc modules 2. python解释器输入:help("modules") ## 目前常用的是pip和easy_in
阅读全文
摘要:(转载) ubuntu 16.04国内下载地址: 中科大源 http://mirrors.ustc.edu.cn/ubuntu-releases/16.04/ 阿里云开源镜像站 http://mirrors.aliyun.com/ubuntu-releases/16.04/ 兰州大学开源镜像站 ht
阅读全文
摘要:# -*- coding: utf-8 -*- # Spyder (python 3.7) import pandas as pd import jieba import jieba.analyse as anls if __name__ == '__main__': data = pd.read_
阅读全文
摘要:1. 统计字符(可以在jieba分词之后使用) 2. 多次覆盖,循环写入文件 比如,循环两次的结果是: 3. 一次性写入文件,中间不会覆盖和多次写入;但是如果重复运行代码,则会覆盖之前的全部内容,一次性重新写入所有新内容
阅读全文
摘要:1. 在计算出混淆矩阵之后,想自己绘制图形(并且在图形上显示汉字),可用 #coding=utf-8 import matplotlib.pyplot as plt import numpy as np confusion = np.array(([91,0,0],[0,92,1],[0,0,95]
阅读全文
摘要:回车+换行 回车 \r 本义是光标重新回到本行开头,r的英文return,控制字符为CR,即Carriage Return; 换行 \n 本义是光标往下一行(不一定到下一行行首),n的英文newline,控制字符为LF,即Line Feed; 换行的ASCII码是10,回车的ASCII码是13。 然
阅读全文
摘要:1. ast包 2. 通过json格式转换 3. 通过eval函数转换
阅读全文
摘要:Windows下Anaconda操作:在Anaconda Prompt下执行 1. Anaconda 更新 conda update conda conda update anaconda conda update python conda update --all #更新包 2. 包管理 cond
阅读全文
摘要:#coding=utf-8 import xlsxwriter #加载包 myWorkbook = xlsxwriter.Workbook(opath+'/'+file_name+'.xlsx') #opath为目录名,file_name为excel文件名,表示在某路径下创建一个excel文件 sh
阅读全文
摘要:#coding=utf-8 # pip install xlrd import xlrd def read_from_xls(filepath,index_col_list): #filepath:读取文件路径,例如:filepath = r'D:/Python_workspace/test.xls
阅读全文