Python Pandas Flashcards

1
Q

df.loc[’ ‘]

A

Leidzia is lenteles pasirinkti tam tikra eilute stulpeli .Galima pakonkretinti
df.loc[’ ‘].loc[][]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

df.xs()

A

Kaip ir df.loc tik lengviau istraukti duomenis is lenteles vidaus
Galima pakonkretinti df.xs(1,level=’Num’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

df.dropna()

A

Istrins visus null reiksmes ,bet galima pakonkretinti
df.dropna(thresh=2) dabar istrins tik tuos kurie turi 2 arba daugiau null

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

df.fillna

A

Uzpildis nulines reiksmes
Galima pakonkretinti
df.fillna(value=’Fill Value’)
arba net uzpildyti pasirinkta nuline reiksme vidurkiu
df[‘A’].fillna(value=df[‘A’].mean())

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

KintPav=df.groupby(‘stulpav’)

A

Leidzia grupuoti duomenis
sudeti pvz Kompanijos sales
Galima naudoti
byComp.mean()
byComp.sum()
byComp.std()
Pakonkretinti
byComp.sum().loc[‘FB’]
Arba aplamai kad parodytu apibendrinta lentele (vidurkis,kvartiles…)
df.groupby(‘Company’).describe()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

pd.concat([df1,df2,df3])

A

Sulipdo dataframe
Galima pakonkretinti
pd.concat([df1,df2,df3],axis=1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

pd.merge(left,right,how=’inner’,on=’key’)

A

Sujungia datagrame per kazkuria reiksme kuria nurodome per on=’ ‘
Galima sujungti per kelias reiksmes
pd.merge(left,right,on=[‘key1’,’key2’])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

dfpavadinimas.join(kitoDfPav)

A

Sujungia df per atitinkamas eiluciu reiksmes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

df[‘col2’].unique()

A

Isveda visas reiksmes nekartojant ju
Taip pat norint suzinoti kiek ju yra galima naudoti
df[‘col2’].nunique()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

df[df[‘col1’]>2]
df[(df[‘col1’]>2)&(df[‘col2’]==444)]

A

Isfiltruoja pagal salyga

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

def times2(x):
return x*2

A

Funkcijos pavyzdys

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

df[‘col1’].apply(times2)
df[‘col2’].apply(lambda x:x*2)

A

Naudojant .apply galima panaudoti sukurta,lambda arba esama funkcija dataframe

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

df.columns

A

Isveda dataframe stulpeliu pavadinimus

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

df.sort_values(‘col2’)

A

Leidzia ruziuoti pagal pasirinkta stulpeli

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

df.isnull()

A

Parodo ar dataframe yra nuliniu reiksmiu

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

df.pivot_table(values=”D”,index=[‘A’,’B’],columns=[‘C’])

A

Sukuriamas pivot table pagal D reiksmes ,indeksuojam pagal a ir b stulpelius ,pasirinke stulpeli C

17
Q

pwd

A

Parodo kur kompiuteryje failas

18
Q

pd.read_csv(‘example’)

A

Nuskaito duomenis is csv failo

19
Q

pd.read_excel(‘Excel_Sample.xlsx’,sheet_name=’Sheet1’)

A

Nuskaito duomenis is excelio failo

20
Q

df.to_csv(‘My_output’,index=False)

A

Sukuria csv faila ir ten importuoja duomenis

21
Q

df.to_excel(‘Excel_sample2.xlsx’,sheet_name=”NewSheet”)

A

Sukuria excelio faila ir ten importuoja duomenis

22
Q

df = pd.read_html(‘https://www.fdic.gov/resources/resolutions/bank-failures/failed-bank-list/’)
df[0]

A

Nuskaito duomenis is html svetaines

23
Q

from sqlalchemy import create_engine
engine= create_engine(‘sqlite:///:memory:’)
data.to_sql(‘my_table’,engine)
sqldf=pd.read_sql(‘my_table’,con=engine)
sqldf

A

Sukuriame minimalistine sql engine ,sukuriame faila kur importuosim duomenis ,naudojant ta engine nuskaitome duomenis

24
Q

df1[‘A’].hist(bins=30)

A

Sukuria histograma

25
Q

df2.plot.area(alpha=0.4)

A

Sukuria area diagrama

26
Q

df2.plot.bar(stacked=True)

A

Sukuria stulpeline diagrama

27
Q

df1.plot.scatter(x=’A’,y=’B’,c=’C’,cmap=’coolwarm’)

A

Sukuria scatter diagrama

28
Q

df2.plot.box()

A

Sukuria box diagrama

29
Q

df.plot.hexbin(x=’a’,y=’b’,gridsize=25)

A

Sukuria hex diagrama

30
Q

df2[‘a’].plot.kde()
df2.plot.density()

A

Diagrama pavaizduoti density

31
Q

df3[[‘a’,’b’]].plot.box()

A

Sukuriamos dvi boxplot diagramos