A cikin duniyar yau, ma'amala da bayanai ya zama fasaha mai mahimmanci ga masu haษakawa da manazarta baki ษaya. ฦaya daga cikin ษakin karatu mai ฦarfi wanda ke taimakawa wajen yin nazarin bayanai shine pandas, wanda aka gina a saman Python programming language. A cikin wannan labarin, za mu dubi yadda ake shigar pandas a Python ta amfani da Git, fahimtar aikin ษakin karatu, kuma bincika ayyuka daban-daban waษanda za su taimaka a ayyukan nazarin bayanan mu. Don haka, bari mu nutse a ciki.
Shigar da pandas ta amfani da Git
Don shigar da pandas ta amfani da Git, da farko kuna buฦatar rufe ma'ajiyar pandas daga GitHub zuwa injin ku na gida. Da zarar kun sami kwafin ma'ajiyar, zaku iya bin matakan da aka ambata a ฦasa don saita komai yadda yakamata.
git clone git://github.com/pandas-dev/pandas.git cd pandas python -m venv venv source venv/bin/activate # On Windows use `venvScriptsactivate` pip install -e .
Lambar da ke sama tana yin haka:
- Yana rufe ma'ajiyar pandas.
- Yana canza kundin adireshi na yanzu zuwa babban fayil na pandas.
- Yana ฦirฦira yanayin kama-da-wane da ake kira "venv".
- Yana kunna yanayin kama-da-wane.
- Shigar da pandas a cikin yanayin gyarawa, wanda zai ba ku damar canza lambar tushe kai tsaye.
Yanzu da muka shigar da pandas ta hanyar Git, za mu iya fara aiki da shi a Python.
Farawa da pandas
Don fara amfani da pandas, kuna buฦatar shigo da ษakin karatu a cikin lambar Python ku. Kuna iya yin wannan ta amfani da umarni mai zuwa:
import pandas as pd
Tare da pandas da aka shigo da su yanzu, zaku iya fara aiki tare da saitin bayanai ta nau'i daban-daban, kamar CSV, Excel, ko SQL. Pandas yana amfani da mahimman bayanai guda biyu don sarrafa bayanai: DataFrame da kuma series.
A DataFrame tebur ne mai girma biyu tare da alamar gatura, yayin da jeri mai girma ษaya ne, tsararru mai lakabi. Waษannan tsarin bayanan suna ba ku damar aiwatar da ayyuka daban-daban da nazari akan bayanan ku.
Loda bayanai da bincike
Don nuna yadda ake amfani da pandas, bari mu yi la'akari da saitin bayanan samfurin - fayil ษin CSV tare da cikakkun bayanai game da samfuran daban-daban, nau'ikan su, da farashin su. Kuna iya loda fayil ษin kuma ฦirฦirar DataFrame kamar haka:
data = pd.read_csv('products.csv')
Don duba abubuwan da ke cikin DataFrame, yi amfani da umarni mai zuwa:
print(data.head())
The kai() Aiki yana dawo da layuka biyar na farko na DataFrame. Hakanan zaka iya yin wasu ayyuka kamar ฦididdige ฦididdiga, tace bayanai, da sarrafa ginshiฦai ta amfani da ayyukan pandas.
Kammalawa
Ta wannan labarin, mun koyi yadda ake shigar pandas a Python ta amfani da Git kuma ya bincika ainihin ra'ayoyin ษakin karatu, kamar DataFrames da Series. Bugu da ฦari, mun koyi game da lodawa da bincika bayanai ta amfani da ayyukan pandas. Tare da waษannan mahimman ra'ayoyi, yanzu an sanye ku da ilimin da ake buฦata don aiwatar da ayyukan nazarin bayanai a cikin ayyukanku. Yayin da kuke ci gaba da aiki tare da pandas, tabbatar da bincika ษimbin ayyuka da hanyoyin da wannan ษakin karatu mai ฦarfi zai bayar - akwai ฦarin koyo a cikin duniyar bayanai!