Matsakaicin karkata a cikin Pandas batu ne mai ban sha'awa idan ya zo ga nazarin bayanai da magudi ta amfani da sanannen ษakin karatu na Python Pandas. ฦaya daga cikin mahimman abubuwan da ke nazarin bayanai shine gano bambancin da ke cikin bayanan, wanda za'a iya yi ta hanyar ฦididdige iyakar karkata. A cikin wannan labarin, za mu koyi yadda za a lissafta max ฦetare a Pandas, bincika hanyoyi daban-daban da zurfafa cikin wasu ษakunan karatu da ayyuka masu dacewa waษanda za a iya amfani da su don magance wannan matsala.
Matsakaicin karkata yana nufin matsakaicin bambanci tsakanin ฦima a cikin saitin bayanai da ma'ana ko tsaka-tsakin wannan saitin. A cikin ฦididdiga, karkata yana taimakawa wajen fahimtar tarwatsawa da bambance-bambancen wuraren bayanai a cikin saitin bayanai. Yana da mahimmancin ra'ayi sau da yawa ana amfani dashi a cikin nazarin kuษi, sarrafa sigina, da sauran filayen ฦididdiga.
Maganin Matsala
Don ฦididdige juzu'in max a Pandas, zamu iya farawa ta shigo da dakunan karatu masu mahimmanci da ฦirฦirar samfurin DataFrame. Sa'an nan, za mu lissafta ma'ana ko tsaka-tsakin bayanan kuma mu sami matsakaicin tazara tsakanin kowane ma'anar bayanai da matsakaici / matsakaici. A ฦarshe, za mu yi amfani da aikin max() don nemo ฦima mafi girma a tsakanin waษannan cikakkun karkatattun.
Anan ga lambar misalin da ke nuna yadda ake ฦididdige max a cikin Pandas DataFrame:
import pandas as pd # Sample data data = {'Value': [5, 7, 11, 18, 23, 25, 29, 35, 40, 50]} df = pd.DataFrame(data) # Compute mean and median mean = df['Value'].mean() median = df['Value'].median() # Calculate absolute deviations from mean and median df['Mean Deviation'] = (df['Value'] - mean).abs() df['Median Deviation'] = (df['Value'] - median).abs() # Find max deviation max_mean_deviation = df['Mean Deviation'].max() max_median_deviation = df['Median Deviation'].max() print("Max Deviation from Mean: ", max_mean_deviation) print("Max Deviation from Median: ", max_median_deviation)
Bayanin mataki-mataki
Yanzu bari mu shiga ta hanyar lambar mataki zuwa mataki don fahimtar tsarin ฦididdige max a cikin Pandas DataFrame:
1. Da farko, muna shigo da ษakin karatu na pandas kuma muna ฦirฦirar samfurin DataFrame tare da shafi guda ษaya mai suna 'Value'.
2. Sa'an nan kuma mu lissafta ma'ana da tsaka-tsakin bayanan ta amfani da ma'anar () da kuma tsaka-tsakin () ayyuka da Pandas ke bayarwa.
3. Na gaba, muna ฦididdige madaidaicin ฦetare ga kowane ma'aunin bayanai ta hanyar cire ma'ana da tsaka-tsaki daga ma'auni na bayanai, kuma mu ษauki cikakkiyar ฦimar bambance-bambancen da aka samu.
4. A ฦarshe, muna amfani da aikin max () don nemo madaidaicin ฦima tsakanin madaidaicin ฦetare.
5. Fitarwa zai nuna max ฦetare daga duka ma'ana da tsaka-tsaki na bayanan.
Dakunan karatu masu alaฦa da Ayyuka
- Pandas: Wannan shine babban ษakin karatu na farko da aka yi amfani da shi a cikin wannan labarin, kuma an san shi sosai don ฦarfin sarrafa bayanai. Ayyukan da aka saba amfani da su kamar su ma'ana(), matsakaici (), max(), min(), da abs() wani yanki ne na ษakin karatu na Pandas.
- NumPy: Wannan wani mashahurin ษakin karatu ne na lissafin lissafi a Python, yana ba da tallafi mai yawa don aiki tare da tsararru da ayyukan ฦididdiga. A wasu lokuta, mutum na iya amfani da ayyukan NumPy don cimma ayyuka iri ษaya kamar na Pandas.
a ฦarshe
Gano max ฦetare a cikin Pandas wani muhimmin al'amari ne na nazarin bayanai, yana ba ku damar auna tarwatsawa a cikin tarin bayanai, kuma wannan labarin ya zayyana hanya madaidaiciya don aiwatar da wannan aikin. Ta hanyar amfani da ayyukan Pandas kamar ma'ana (), matsakaici (), abs(), da max(), yana yiwuwa a iya ฦididdige max ฦetare ga kowane saitin bayanai. Bugu da ฦari, ana iya samun irin wannan ayyuka da ayyuka ta amfani da dakunan karatu kamar NumPy, waษanda ke haษakawa da faษaษa iyakokin dabarun sarrafa bayanai da ke akwai ga mai haษakawa.