Changing your clocks this weekend? Or did you do so a few weeks ago? Or maybe you never do?

In the latest Bamboo Weekly, we use #Python #Pandas to see which countries observe DST, and for how long each year.

Check it out: https://BambooWeekly.com

A #Python #Pandas column contains comma-separated values. How can you get the first of those?

First, break each string into a list:

df['x'].str.split(',')

Then use .str[0] to grab the first element from the resulting list:

df['x'].str.split(',').str[0]

Want to check whether a #Python #Pandas string series only contains digits? Use str.isdigit:

df['x'].str.isdigit()

This returns a boolean series, with df's index. You can then convert the digit-containing strings to integers:

df.loc[pd.col('x').str.isdigit(), 'x'].astype(int)

Want to retrieve a slice from a string column in your #Python #Pandas data frame? Use .str.slice:

df['a'].str.slice(1, 10) # or .str[1:10]
df['a'].str.slice(1, 10, 2) # or .str[1:10:2]
df['a'].str.slice(None, 10) # or .str[:10]
df['a'].str.slice(1, None) # or .str[1:]

Want to retrieve from a string column in your #Python #Pandas data frame? Use .str.get:

df['a'].str.get(0) # one character
df['a'].str.get(i) # using an index variable

But wait: You can use [], in place of .get:

df['a'].str[0] # alt syntax!

A recent paper finds that when new albums drop, streaming traffic increases — and so do traffic fatalities. 🤯

In today's Bamboo Weekly, we investigate this data with #Python #Pandas, using a variety of data-analysis techniques — grouping, joins, and datetime values.

Level up your data-analysis skills every Wednesday, at https://BambooWeekly.com

Your #Python #Pandas data frame has a multi-index, and you want to remove one part — not return it to be a regular column? Add drop=True:

df.reset_index(level=1) # index level 1 becomes a column in df
df.reset_index(level=1, drop=True) # index level 1 is removed

🌗 101 道 Pandas 數據分析練習題(互動式)
➤ 從基礎語法到深度學習:打造專業數據科學家的實戰指南
https://machinelearningplus.com/python/101-pandas-exercises-python-interactive/
本文介紹了 MachineLearningPlus 網站提供的全方位數據科學學習資源,核心亮點為一系列結構化的練習題,特別是「101 道 Pandas 練習題」。這些資源涵蓋了從 Python 基礎、機器學習算法、時間序列預測到深度學習與產業實戰項目等廣泛領域。該平臺透過系統化的練習與教學,協助數據分析師與工程師在實戰中熟練掌握 Pandas 等核心工具,提升處理大型數據集及建立機器學習模型的專業能力。
+ 這些練習題簡直是學習 Pandas 的救星,對於想紮實建立資料處理邏輯的人來說非常實用。
+ 資源庫的廣度令人驚艷,從基礎 Python 到高級的雲端部署都有涉及,是一個很完整的學習路徑。
#資料科學 #Python 教學 #Pandas 實作
101 Pandas Exercises for Data Analysis (Interactive) - machinelearningplus

101 interactive pandas exercises with solutions. Edit and run every code block directly in your browser — no installation needed.

machinelearningplus
101 Pandas Exercises for Data Analysis (Interactive) - machinelearningplus

101 interactive pandas exercises with solutions. Edit and run every code block directly in your browser — no installation needed.

machinelearningplus

Tom is now listening to Find You
https://open.spotify.com/track/5IzVL3gIya2cbzeZTcvyY7

#Pandas&People