Last active
August 24, 2020 17:11
-
-
Save fk-pixel/acb408a2d602e24ae17704be00f58338 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#yukarda daha önceden tanimlanmis bir 'max_infection_rates' varsa 'max_infection_rate' sütununu eklemek icin: | |
corona_dataset_aggregated["max_infection_rate"] = max_infection_rates | |
#sadece bu sütunu diger sütunlar olmaksizin göstermesi icin: | |
corona_data = pd.DataFrame(corona_dataset_aggregated["max_infection_rate"]) | |
corona_data.head() | |
#kullanilmayacak sütunlardan kurtulma: | |
#önce hangi sütunlari istemiyoruz listeleyelim: | |
useless_cols = ["Overall rank","Score","Generosity","Perceptions of corruption"] | |
#kullanmayacagimiz sütunlari useless olarak belirtmistik simdi "axis=1 ,inplac=True" ile yeni hali olusturalim: | |
#veri cercevesini yerinde degistirelim, yeni bir nesne olusturmayalim | |
happiness_report_csv.drop(useless_cols, axis=1, inplace=True) | |
happiness_report_csv.head() | |
#sütun olarak satirdan baslik alma: | |
#input: | |
df = pd.DataFrame({'month': [1, 4, 7, 10], | |
'year': [2012, 2014, 2013, 2014], | |
'sale': [55, 40, 84, 31]}) | |
df | |
#output: | |
month year sale | |
0 1 2012 55 | |
1 4 2014 40 | |
2 7 2013 84 | |
3 10 2014 31 | |
#Simdi dizini "ay" sütunu olacak şekilde ayarlarsak: | |
df.set_index('month') | |
#output2: | |
year sale | |
month | |
1 2012 55 | |
4 2014 40 | |
7 2013 84 | |
10 2014 31 | |
#2.bir örnek: | |
happiness_report_csv.set_index("Country or region",inplace=True) | |
happiness_report_csv.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment