美文网首页数据蛙数据分析每周作业
数据分析第一周学习总结

数据分析第一周学习总结

作者: f9d51cebc219 | 来源:发表于2020-03-22 14:55 被阅读0次

    3月18号晚上加入就业班学习,之前自学过SQL、Python、Linux、Git,还有一些杂七杂八的东西。不是完全没有基础,毕业也快2年了也没有真正的入行,希望尽快完成一个作品成功转行。制定的计划是先花时间把之前学过的最相关的技能捡起来,做些面试题,然后尽快完成一个项目。

    SQL

    最开始觉得自己应该掌握了SQL的所有查询,在做题的过程中发现了一些自学没有学到的知识点,仅仅知道SELECT FROM 这些语句的基本使用不足以应对各种需求,以下列举一些自己遇到的自己理解不深和没有掌握的知识点

    ON AND 和 ON WHERE

    在完成以到SQL练习题的时候自己先是写了一个ON AND 的语句

    select * from sc a left join sc b on a.sid = b.sid and a.cid = '01' and b.cid = '02';
    

    对照答案的查询结果发现多了一些不满足要求的数据最后知道了查询语句连接表后接ON AND 和 ON WHERE是有区别的

    1. on的条件是在连接生成临时表时使用的条件,以左表为基准 ,不管on中的条件真否,都会返回左表中的记录,on 后面 and 都是对右表进行筛选
    2. where是全部连接完后,对临时表进行筛选,筛选对左表和右表都有效

    在使用联结时,不管是对左表还是右表进行筛选,on and和on where都会对生成的临时表进行过滤。

    @定义变量

    在各种在线教程中没有看到这块的知识点,这允许SQL能够实现一些其他的功能,目前就了解了排序

    在做题时看到了使用变量来排序的语句,最开始只能对照答案理解,连续几道题出现了一句类似无意义的代码select @rank:=0,@sco:=null单独运行这条语句会发现没有任何有意义的数据

    类似做排序的语句case when (@sco=score) then @rank else @rank:=@rank+1 end这是一条对成绩做排序的语句,单单观察两条语句会想把第一条语句删掉,但这会出现一些问题,如果运行两次查询语句,排名所在的列不会从1开始排序而是从上次结束的位置开始排序

    猜想是在执行完查询语句之后变量并不会被清空而会继续存在,那么select @rank:=0,@sco:=null的意义差不多明白了,就是在查询之前做初始化,这样就避免了排序的自增问题

    Python

    之前看过廖雪峰的教程,当时卡在了面向对象和装饰器上,线程方面也并不是非常了解,目前遇到的问题主要是第三方库的使用,单单一个pandas库就有非常多的没有见过的函数,一些常见的函数例如sum()也有与之对应的非常多的参数其中还有一些其他函数的细节,目前只能积累没有更好的办法

    Pandas

    学习了一些使用Pandas完成Excel操作的一些函数例如groupby()pivot_table()

    有时候pivot_table()会报错,查询到Pandas文档说明pandas.pivot_table(data, values=None, index=None, columns=None, aggfunc='mean', fill_value=None, margins=False, dropna=True, margins_name='All', observed=False)

    传入data时会报错,Pandas函数不同版本传入参数可能有所不同,有时需要去掉一些参数

    在Pandas中有与SQL联结对应的函数使用方法为

    DataFrame.join(self, other, on=None, how='left', lsuffix='', rsuffix='', sort=False)
    

    其中的参数说明

    otherDataFrame, Series, or list of DataFrame
    Index should be similar to one of the columns in this one. If a Series is passed, its name attribute must be set, and that will be used as the column name in the resulting joined DataFrame.
    
    onstr, list of str, or array-like, optional
    Column or index level name(s) in the caller to join on the index in other, otherwise joins index-on-index. If multiple values given, the other DataFrame must have a MultiIndex. Can pass an array as the join key if it is not already contained in the calling DataFrame. Like an Excel VLOOKUP operation.
    
    how{‘left’, ‘right’, ‘outer’, ‘inner’}, default ‘left’
    How to handle the operation of the two objects.
    
    left: use calling frame’s index (or column if on is specified)
    
    right: use other’s index.
    
    outer: form union of calling frame’s index (or column if on is specified) with other’s index, and sort it. lexicographically.
    
    inner: form intersection of calling frame’s index (or column if on is specified) with other’s index, preserving the order of the calling’s one.
    
    lsuffixstr, default ‘’
    Suffix to use from left frame’s overlapping columns.
    
    rsuffixstr, default ‘’
    Suffix to use from right frame’s overlapping columns.
    
    sortbool, default False
    Order result DataFrame lexicographically by the join key. If False, the order of the join key depends on the join type (how keyword).
    

    这样就可以用Python实现SQL类似的功能

    单单一个Pandas库就有非常多的函数,其中函数的各个参数也是非常难以记忆,熟悉一些常用的函数及其参数在有需求时再查找需要的函数非常重要

    相关文章

      网友评论

        本文标题:数据分析第一周学习总结

        本文链接:https://www.haomeiwen.com/subject/bqymyhtx.html