PANDAS(15)
-
[LeetCode] Pandas / 2891. Method Chaining
문제 링크https://leetcode.com/problems/method-chaining/description/ 문제 코드import pandas as pddef findHeavyAnimals(animals: pd.DataFrame) -> pd.DataFrame: return animals[animals['weight']>100].sort_values(['weight'], ascending=False)[['name']]
2024.07.08 -
[LeetCode] Pandas / 2890. Reshape data: Melt
문제 링크https://leetcode.com/problems/reshape-data-melt/description/ 문제 코드import pandas as pddef meltTable(report: pd.DataFrame) -> pd.DataFrame: return report.melt(id_vars=['product'], var_name='quarter', value_name='sales')
2024.07.08 -
[LeetCode] Pandas / 2889. Reshape data: Pivot
문제 링크https://leetcode.com/problems/reshape-data-pivot/description/ 문제 코드import pandas as pddef pivotTable(weather: pd.DataFrame) -> pd.DataFrame: return weather.pivot(index='month', columns='city', values='temperature')
2024.07.08 -
[LeetCode] Pandas / 2888. Reshape data concatenate
문제 링크https://leetcode.com/problems/reshape-data-concatenate/description/ 문제 코드 import pandas as pddef concatenateTables(df1: pd.DataFrame, df2: pd.DataFrame) -> pd.DataFrame: return pd.concat([df1, df2])
2024.07.08 -
[LeetCode] Pandas / 2887. Fill missing data
문제 링크https://leetcode.com/problems/fill-missing-data/description/ 문제 코드 import pandas as pddef fillMissingValues(products: pd.DataFrame) -> pd.DataFrame: products["quantity"]=products["quantity"].fillna(0) return products
2024.07.08 -
[LeetCode] Pandas / 2886. Change data type
문제 링크 https://leetcode.com/problems/change-data-type/description/ 문제 코드import pandas as pddef changeDatatype(students: pd.DataFrame) -> pd.DataFrame: students['grade']=students['grade'].astype(int) return students
2024.07.08