Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python
Python
  1. Python Pandas - เรียงลำดับค่า Index และคืนดัชนีที่จะทำให้ Index เรียงลำดับ

    เพื่อเรียงลำดับค่า Index และคืนดัชนี (indices) ที่จะทำให้ Index เรียงลำดับ ให้ใช้เมธอด index.sort_values() พร้อมตั้งค่าพารามิเตอร์ return_indexer เป็น True เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd สร้าง Pandas Index: index = pd.Index([50, 10, 70, 95, 110, 90, 30]) แสดง Pandas In

  2. Python Pandas - ดึงจำนวนวินาทีทั้งหมด (Total Seconds) จาก Timedelta object

    เพื่อดึงจำนวนวินาทีทั้งหมด (total seconds) ในระยะเวลาจาก Timedelta object ให้ใช้เมธอด timedelta.total_seconds() เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd TimeDeltas เป็นไลบรารี datetime มาตรฐานของ Python ใช้การแทนค่าที่ต่างกัน สร้าง Timedelta object: timedelta = pd.Timedelta(2 day

  3. Python Pandas - ผนวก (Append) ชุด Index หลายชุดเข้าด้วยกัน

    เพื่อผนวก (append) ชุด Index หลายชุดเข้าด้วยกัน ให้ใช้เมธอด append() ใน Pandas เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd สร้าง Pandas Index: index1 = pd.Index([10, 20, 30, 40, 50]) แสดง Pandas Index: print(Pandas Index...\n, index1) สร้าง Index ใหม่ที่จะผนวก: index2 = pd.Index([

  4. Python Pandas - ดึงวันของเดือน (Day of Month) ที่ Period ตรงกับอยู่

    เพื่อดึงวันของเดือน (day of the month) ที่ Period ตรงกับอยู่ ให้ใช้ property period.day เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd pandas.Period แทนช่วงเวลา สร้าง Period object สองตัว: period1 = pd.Period(2021-09-18) period2 = pd.Period(freq=D, year=2021, month=9, day=22, hour=4, m

  5. Python Pandas - หา Intersection ของสอง Index objects

    เพื่อหา Intersection (เซตตัดกัน) ของสอง Index objects ให้ใช้เมธอด index1.intersection(index2) ใน Pandas เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd สร้าง Pandas Index สองชุด: index1 = pd.Index([10, 20, 30, 40, 50]) index2 = pd.Index([80, 65, 60, 70, 55]) แสดง Pandas index1 และ inde

  6. Python Pandas - ดึงวันของสัปดาห์ (Day of Week) ที่ Period อยู่

    เพื่อดึงวันของสัปดาห์ (day of the week) ที่ Period ตรงกับอยู่ ให้ใช้ property period.dayofweek เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd pandas.Period แทนช่วงเวลา สร้าง Period object สองตัว: period1 = pd.Period(2021-09-18) period2 = pd.Period(freq=D, year=2021, month=9, day=22, ho

  7. Python Pandas - ดึงวันของปี (Day of Year) จาก Period object

    เพื่อดึงวันของปี (day of the year) จาก Period object ให้ใช้ property period.dayofyear เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd pandas.Period แทนช่วงเวลา สร้าง Period object สองตัว: period1 = pd.Period(2020-09-23) period2 = pd.Period(freq=D, year=2021, month=7, day=16, hour=2, min

  8. Python Pandas - หา Intersection ของสอง Index objects และเรียงลำดับผลลัพธ์

    เพื่อหา Intersection (เซตตัดกัน) ของสอง Index objects และเรียงลำดับผลลัพธ์ ให้ใช้เมธอด index1.intersection(index2) ใน Pandas พร้อมพารามิเตอร์ sort เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd สร้าง Pandas index1 และ index2: index1 = pd.Index([4, 3, 2, 1]) index2 = pd.Index([8, 2, 6,

  9. Python Pandas - ดึงจำนวนวันทั้งหมดของเดือนที่ Period ตรงกับอยู่

    เพื่อดึงจำนวนวันทั้งหมดของเดือนที่ Period ตรงกับอยู่ ให้ใช้ property period.daysinmonth เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd pandas.Period แทนช่วงเวลา สร้าง Period object สองตัว: period1 = pd.Period(2020-09-23) period2 = pd.Period(freq=D, year=2021, month=2, day=14, hour=2, m

  10. Python Pandas - รวม Union ของสอง Index objects

    เพื่อรวม Union ของสอง Index objects ให้ใช้เมธอด index1.union(index2) ใน Pandas เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd สร้าง Pandas Index สองชุด: index1 = pd.Index([10, 20, 30, 40, 50]) index2 = pd.Index([80, 65, 60, 70, 55]) แสดง Pandas index1 และ index2: print(Pandas Index1..

  11. Python Pandas - ดึงความถี่ (Frequency) ของ Period object ที่กำหนด

    เพื่อดึงความถี่ (frequency) ของ Period object ที่กำหนด ให้ใช้ property period.freq เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd pandas.Period แทนช่วงเวลา สร้าง Period object สองตัว: period1 = pd.Period(2020-09-23 03:55:20) period2 = pd.Period(freq=T, year=2021, month=2, day=14, hour=

  12. Python Pandas - หาเวลาสิ้นสุด (End Time) ของ Period object ที่กำหนด

    เพื่อหาเวลาสิ้นสุด (end time) ของ Period object ที่กำหนด ให้ใช้ property period.end_time เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd pandas.Period แทนช่วงเวลา สร้าง Period object สองตัว: period1 = pd.Period(2020-09-23 03:55:20) period2 = pd.Period(freq=T, year=2021, month=2, day=14,

  13. Python Pandas - ดึงชื่อตัวแทนสตริง (String Alias) ของความถี่ Time Series จาก Period object

    เพื่อดึงชื่อตัวแทนสตริง (string alias) ของความถี่ Time series ที่นำไปใช้กับ Period object ที่กำหนด ให้ใช้ property period.freqstr เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd pandas.Period แทนช่วงเวลา สร้าง Period object สองตัว: period1 = pd.Period(2020-09-23 03:55:20) period2 = pd.P

  14. Python Pandas - ดึงชั่วโมง (Hour) ของวันจาก Period object

    เพื่อดึงส่วนประกอบชั่วโมงของวัน (hour of the day) จาก Period object ให้ใช้ property period.hour เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd pandas.Period แทนช่วงเวลา สร้าง Period object สองตัว: period1 = pd.Period(2020-09-23 05:55:30) period2 = pd.Period(freq=H, year=2021, month=7,

  15. Python Pandas - ตรวจสอบว่าปีเป็นปีอธิกสุรทิน (Leap Year) จาก Period object

    เพื่อตรวจสอบว่าปีเป็นปีอธิกสุรทิน (leap year) จาก Period object ให้ใช้ property period.is_leap_year เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd pandas.Period แทนช่วงเวลา สร้าง Period object สองตัว: period1 = pd.Period(2020-09-23 05:55:30) period2 = pd.Period(freq=Y, year=2021, month

  16. Python Pandas - ดึงนาที (Minute) ของชั่วโมงจาก Period object

    เพื่อดึงส่วนประกอบนาทีของชั่วโมง (minute of the hour) จาก Period object ให้ใช้ property period.minute เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd pandas.Period แทนช่วงเวลา สร้าง Period object สองตัว: period1 = pd.Period(2020-09-23 05:55:30) period2 = pd.Period(freq=T, year=2021, mon

  17. Python Pandas - ดึงเดือน (Month) ของปีจาก Period object

    เพื่อดึงส่วนประกอบเดือนของปี (month of the year) จาก Period object ให้ใช้ property period.month เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd pandas.Period แทนช่วงเวลา สร้าง Period object สองตัว: period1 = pd.Period(2020-09-23 05:55:30) period2 = pd.Period(freq=M, year=2021, month=8,

  18. Python Pandas - ดึงไตรมาส (Quarter) ของปีจาก Period object

    เพื่อดึงส่วนประกอบไตรมาสของปี (quarter of the year) จาก Period object ให้ใช้ property period.quarter เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd pandas.Period แทนช่วงเวลา สร้าง Period object สองตัว: period1 = pd.Period(2020-02-27 08:32:48) period2 = pd.Period(freq=M, year=2021, mont

  19. Python Pandas - รวม Union ของสอง Index objects แต่ไม่เรียงลำดับผลลัพธ์

    เพื่อรวม Union ของสอง Index objects และไม่เรียงลำดับผลลัพธ์ ให้ใช้เมธอด index1.union(index2) พร้อมพารามิเตอร์ sort=False เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd สร้าง Pandas Index สองชุด: index1 = pd.Index([10, 20, 30, 40, 50]) index2 = pd.Index([80, 65, 60, 70, 55]) แสดง Panda

  20. Python Pandas - ดึงส่วนประกอบวินาที (Second) จาก Period object

    เพื่อดึงส่วนประกอบวินาที (second component) จาก Period object ให้ใช้ property period.second เริ่มต้นด้วยการนำเข้าไลบรารีที่จำเป็น: import pandas as pd pandas.Period แทนช่วงเวลา สร้าง Period object สองตัว: period1 = pd.Period(2020-09-23 05:55:30) period2 = pd.Period(freq=S, year=2021, month=7, day=

Total 9001 -คอมพิวเตอร์  FirstPage PreviousPage NextPage LastPage CurrentPage:385/451  20-คอมพิวเตอร์/Page Goto:1 379 380 381 382 383 384 385 386 387 388 389 390 391